04. LINUX commands(3) - Uchiha3000/LINUX_docx GitHub Wiki
LINUX commands part 3
How many commands are there to create a file?
code: touch AF01 (touch space filename), cat > AF02 (cat space > space filename), cat >> AF03 (cat space >> space filename)
How to use copy paste function in windows?
code: cp AD01/ASD02/AF01 AD02/AF01 OR cp AD01/ASD02/AF01 AD02/ (Note: cp space file-source space file-destination) (Note: If you don't write the file name in the destination it will show the same filename from the file source i.e. AF01)
How to rename a file using copy paste in LINUX?
code: cp AD01/ASD02/AF01 AD02/AF01.new (Note: The pasted file will be renamed as AF01.new)
How to copy all contents from a directory and paste it into another directory?
code: cp AD01/* AD03/
How to cut paste files in LINUX?
code: mv AF02 AD02/AF02 (Note: mv filename or file path space file destination)
How to rename a file?
code: mv AF03 AkashFile03
How to copy paste directories?
code: cp -r AD01 AD02 (Note: cp space -r space filename file-destination)
How to see all content inside a directory?
code: ls -R AD02 or ls -Rl AD02 (Note: The "-R" stands for recursive. This command will show all contents inside a directory even the sub directories content, like the tree views in windows)
How to move an entire directory into another directory?
code: mv AD01 AD03
How to remove a file?
code: rm AF01 (Note: In LINUX we don't have access to recycle bin. That access is only present with system administrator.
How to remove an empty directory?
code: rmdir dr (Note: rmdir space directory name)
How to remove a directory that is not empty?
code: rm -r AD02
How to check the number of lines in a file?
code: wc -l fl02
How many words are there in a file?
code: wc -w fl02
How many characters are there in a file?
code: wc -c fl02
How to search a particular word in a file?
code: grep test fl02 (Note: grep space word-to-be-searched space filename. Be careful because if the word is not typed properly it may return empty since it is case-sensitive.)
How to search a particular word in a file without it being case sensitive?
code: grep -i Test fl02 (Note: The "-i" ignores the case sensitivity)
How to ignore a line which has the word test but the rest of the lines should be shown?
code: grep -v test fl02
Ho to delete all directories? [WARNING: Never do it in practice]
code: rm -rf * (Note: "*" represents all and "-rf" is for forcefully removing)
How to create 5 directories at a single command?
code: mkdir D01 D02 D03 D04 D05
How to create a hidden file?
code: touch .AkashHidden
How to unhide a hidden file?
code: mv .AkashHidden AkashUnhidden