Comprehensive Guide to File Management in Linux
Commands used for File Management
pwd
- Present working directoryls
- To list the files and folders from the current directoryls -a
- To list all the files and folders from the current directory including hidden files and folderscd
- Change Directorycd /
- Take the control to root directorycd ~
- Take the control to home directorycd ..
- Move back to previous directorymkdir <dir name>
- To Create Directorymkdir .<dir name>
- To Create hidden Directory
Create Files in Directory :
echo “<message>”
- echo Command is to used print any message to the terminal.touch <file_name>
- Create Empty filetouch .file_name
- Create Hidden Fileecho “<message>” >> file_name
- Create a file with contentcat file_name
- Read the contents of the a fileecho “<message>” > file_name
- Replace the file contentvi file_name
- Create/Open a file using vi editorEg. vi test1
press i # Goto Insert Mode
//Type the File Contents
press esc :wq # Save and Exit from that file
press esc :q! # Exit without saving the file
cp file_name <Target_Dir_Name>
- Copy file to another directorymv file_name <Target_Dir_Name>
- Move file to another directorymv existing_file_name <new_file_name>
- Rename the Filerm <file_name>
- Remove a filerm -rf <dir name>
- Remove a directoryll
- Long Listing