Logged In User Details:
- whoami (Shows the username of the logged in user)
Directory Operations:
- pwd (Gives Present Working Directory)
- cd /dir (Navigate to 'dir' directory)
- mkdir dev (Make 'dev' directory)
- cd .. (Go to parent directory of the current directory)
- cd / (Go to root directory)
- cd ~ (Go to home directory)
File Listing Operations:
- ls (To list the files in the current directory)
- ls -a (To list all the files including hidden files)
- ls -l (To list the files with permissions)
- ls -t (To sort the list of files by last modified)
- ls -S (To sort the list of files by size)
- ls -R (To show the recursive list)
- ls -1 (One file per line)
- ls -r (To list the files in reverse order)
File Permission Numbers:
- 4 (Read)
- 2 (Write)
- 1 (Execute)
File Permission Operations:
- chmod 777 filename (Change mode of file to 777)
- chmod -R 666 foldername (Change mode of folder to 666 recursively i.e including its subfolders as well)
- chown (Used to change the file owner or the group)
- chown new_owner_name filename (Owner of filename will be changed to new_owner_name)
- chown :dev file1.txt (group owner of file1.txt will be changed to dev)
- chown master:dev file.txt (group owner as well as the owner of file1.txt will be changed to master:dev)
Different ways to switch to the root user:
- sudo -i
- sudo -s
- su -i
- su -
How to change a password:
- passwd username
How to add a new user:
- useradd username
How to see the details of user like uid and the groups to which he belongs
- id username
How to remove a user:
- userdel username
- userdel -r username (Deletes the user along with its home directory)