Linux -File Commands

Bhanuprakash Veluru
2 min readOct 19, 2022

--

  1. pwd — will display current working directory
  2. ls — will list down the file and folders in directory
  3. mkdir <dir_name> — will be used to create an empty directory
  4. touch <file_name> — will be used to create empty file

. create file without extension — touch myfile

  • create file with extension — touch myfile.txt
  • create multiple files — touch file1.txt file2.txt

5. rmdir <dir_name> — command is used to remove directory

rmdir -rf <dir_name> — command is used to remove all subdirectories with force(No popup or notification)

6. rm <filename> — command to delete file

rm -f <filename> — command to force delete file

7. cd <dir_name> — used for switching between directories

8. cat <filename> — display the content of the file in the terminal

9. echo “Hi everyone” — command display message in the terminal

echo “Hi everyone” >> file1.txt — this way we can write data to file1.txt

10. vim file1.txt — this will create a file and open in vim editor

we can enter our data by pressing “i”

to come out the vim editor we use “ESC” “:wq” (w- for save)(q-quit)

11.ls -l — this will display files and folder along with permission given to user

12. chmod — By using this command we can change the permission of the file or folder

4 — Read

2- write

1- Execute

chmod 000 <dir/filename> — this command will give only read permission to user

chmod 700 filename — this will proved read/write execute permission to assigned user. For group members and others they don’t have any permission

chmod 777 filename — this will provide read/write/execute permissions to all user , groups and others in the system.

--

--