- Sudo su
"sudo" stands for "superuser do". It allows a permitted user to execute a command as the superuser or another user.
"su" stands for "switch user".
The hyphen (-) at the end is a shorthand for "-l" or "--login", which provides a full login shell.
(This is just for knowing, not necessary used for now)...just knowing is good.
- pwd (Print Working Directory)
The pwd command shows your current location in the file system.
- ls (List Directory Contents)
The ls command lists files and directories in your current location.
- ls -la (Detailed List View)
Adding the -la
options to ls
provides a detailed, long-format list that includes hidden files, hidden files have "." in front of them.
- cd (Change Directory)
Initially we were in /home/kali, when we write cd Desktop, path changes to /home/kali/Desktop.
- cd .. (Reverse Directory)
- This command helps to go back to the previous directory.
- Let's say you are in Desktop directory but you want to go back to kali directory
- You can do it by typing:
cd ..
- Mkdir (Make a new Subdirectory)
- It is used to make a new folder. Let's make a new folder in the Desktop by first changing the directory to Desktop, and typing:
mkdir filename
Example:
mkdir helloworld
This will create a folder named helloworld in the Desktop.
- touch
- The primary purpose of the
touch
command is to update the access and/or modification date of a file or directory. However, it can also be used to create a file if it doesn't exist. - Let's create a file named
file.txt
in thehelloworld
folder. The first step would be changing the directory to thehelloworld
folder if not done, then typing:
touch file.txt
- cp (copy)
- Let's say we want to copy the file.txt to a new folder named "newfolder", we can do it by first creating a newfolder in the desktop, now the desktop will have two folders, one being the helloworld folder which contains the file.txt and a new empty folder named "newfolder"
- To copy the file.txt what we can do is, type:
cp ~/Desktop/helloworld/file.txt ~/Desktop/newfolder/
Basically what we are doing is, taking the path of the file.txt i.e. ~/Desktop/helloworld/file.txt (which is inside helloworld folder in desktop) and copying it to where we want to copy it, i.e. ~/Desktop/newfolder/ (inside newfolder).
- mv (move)
Let's say we want to move the file.txt from "helloworld" folder to "newfolder", so that helloworld folder has nothing inside, and only the newfolder will have file.txt inside it.
We can do it by typing:
mv ~/Desktop/helloworld/file.txt ~/Desktop/newfolder/
Here too, basically what we are doing is, taking the path of the file.txt i.e. ~/Desktop/helloworld/file.txt (which is inside helloworld folder in desktop) and moving it to where we want to move it, i.e. ~/Desktop/newfolder/ (inside newfolder).
Top comments (2)
The actual purpose of
touch
is to update the access date and/or modification date of a file or directory. The fact that it will create a file if it doesn't exist is merely a convenient side effectHello Jon!! Thank you for your insightful comment. I really appreciate the clarification and have updated my post. Thank you for contributing.