Day'06 -linux Command Part-02

rmdir(remove directory)- It removes the directory
rmdir <file/directory name>
rm(remove)- It removes both empty and non-empty files/directory
rm <file/directory name>
rm -r : recurcively deletes all the content and sub folders/ files
rm -r <file/directory name>
rm -rf : forcefully deletes the files/directory
rm -rf <file/directory name>
tree - To view the directories and its sub directories/ files in an hierarchy manner
Before executing the tree command, we need to install the tree by using yum
yum install tree (in admin access by using ‘sudo’)
cat * - To view all the content of all the files in root directory
cat > file.txt - To create a file, without opening the file screen, can enter and can edit the file in gitblash screen only.
press ctrl d to exit from it.
cat » file.txt - To update the file file.txt
tac file.txt - To display the file content in reverse order
cp - To copy the file/directory from one directory to another.
synx: cp source destination
sweety.txt file is copied to linux directory
cp * - To copy ‘n’ files
cp . - Every file/directory will be copied
cp -r . /tmp ( The files & directories from present working directory will be copied to tmp directory)
mv - To move the content from one file/directory to another
For renaming also ‘mv’ is used
tile - To display the last few lines of content of file, default it selects 10 lines
- head - To display the first few lines of content of file, default it selects 10 lines
head -n 3 file.txt - To display first 3 lines of file content
tail -n 3 file.txt - To display last 3 lines of file content
sort - To view the file content in sorting format
sort file.txt (ascending order)
sort -r file.txt (descending order)
sort -u file.txt (To remove duplicate)
sort -ur file.txt (To remove duplicate and view in reverse order)
Subscribe to my newsletter
Read articles from Sandhya Kalikiri directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
