The document discusses Linux commands for file management. It describes commands for creating directories (mkdir), listing files (ls), changing directories (cd), printing the current working directory (pwd), copying files (cp), moving and renaming files (mv), removing files and directories (rm), and finding files (find). For example, mkdir creates directories, ls lists files with options for long or modified time listings, and cd changes the current directory to a specified location or up one level.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
695 views
Linux Commands - File Management
The document discusses Linux commands for file management. It describes commands for creating directories (mkdir), listing files (ls), changing directories (cd), printing the current working directory (pwd), copying files (cp), moving and renaming files (mv), removing files and directories (rm), and finding files (find). For example, mkdir creates directories, ls lists files with options for long or modified time listings, and cd changes the current directory to a specified location or up one level.
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1
Linux Commands fie management
1. mkdir : Creates a directory
Eg. mkdir dir1 2. ls : lists all the files and directories in the current directory. Eg. ls ? Simple listing. ls -l ? long listing(includes permissions,size etc.) ls -t ? lists in the modification time order ls -a ? lists all files(including hidden files) 3. cd : Changes the directory. Eg. cd dir1 ? Change to dir1 cd .. ? You will move one level up in the directory hierarchy i.e, going into the parent directory. cd ? takes to your home directory. Default directory is your home directory. 4. pwd : prints the path of the current working directory 5. cp : copy the contents from source to destination Eg. cp file1.txt file2.txt ?Make a copy of file1.txt and names it as file2.txt cp file1.txt dir1 ? copies the file1.txt into directory dir1. The file will have same name file1.txt in dir1. 6. mv: Eg. mv file1.txt file2.txt ? renames the file1.txt with file2.txt. Use ls to see the result. Now you don t find file1.txt. mv file1.txt dir1 ? moves file file1.txt in to directory dir1. The file is deleted in the current directory and in dir1 it will have the same name file1.txt 7. rm: Removes files or directories Eg. rm file1.txt ? Removes file1.txt rm -f file1.txt ? Removes the file with our asking for confirma- tion(forceful removing) rm -rf dir1 ? Removes the directory dir1 recursively,i.e, it will delete all the directory hierarchy below the dir1 also. Note: Use rm command with extreme caution. Data will be lost forever. If the you don t have the write permission for that file and you are trying to remove that file, then it asks your confirmation for the deletion of a file. 8. find: Search for a file or directory. Eg. find -name file1.txt ? searches for file1.txt in the current directory hierarchy.