Basic Unix commands-2
6. ls command
Syntax ls [options]
Description:
-a shows all file including hidden files
-d If an argument is a directory it only lists its name not
its contents
-p displays a slash(/) in front of all directories
-r reverses the order of how the files are displayed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tkanu025@hp:~$ ls | |
avengers ff-series insta oop os | |
tkanu025@hp:~$ ls -p | |
avengers/ ff-series/ insta/ oop/ os/ | |
tkanu025@hp:~$ ls -r | |
os oop insta ff-series avengers | |
tkanu025@hp:~$ ls -A | |
.bash_history .bash_logout .bashrc .landscape .motd_shown .profile avengers ff-series insta oop os | |
tkanu025@hp:~$ ls -a | |
. .. .bash_history .bash_logout .bashrc .landscape .motd_shown .profile avengers ff-series insta oop os | |
tkanu025@hp:~$ ls ff-series -d | |
ff-series | |
tkanu025@hp:~$ ls ff-series | |
ff6 ff7 ff9 | |
tkanu025@hp:~$ |
7. Echo command
It prints the given input string to standard output.(It is same as printf("")
in c programming language).
syntax: eco 'string'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tkanu025@hp:~$ echo "hello to the world of Linux" | |
hello to the world of Linux | |
tkanu025@hp:~$ echo 'this is echo command' | |
this is echo command | |
tkanu025@hp:~$ |
8. mkdir command
This command is used to create a new repository
Syntax: mkdir [options] [directory name]
All options can be used as per requirements
directory name is the mane of the folder which you want to create
-m set permission mode (as in chmode)
-p No error if existing, make parent directories as needed.
-v Print a message for each created directory
directory name is the mane of the folder which you want to create
-m set permission mode (as in chmode)
-p No error if existing, make parent directories as needed.
-v Print a message for each created directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tkanu025@hp:~$ ls | |
avengers ff-series insta oop os | |
tkanu025@hp:~$ mkdir Bond007 | |
tkanu025@hp:~$ ls | |
Bond007 avengers ff-series insta oop os | |
tkanu025@hp:~$ |
9. rmdir command
Description:
It is used to delete a directory and its subdirectories.
it only removes empty directory.
it only removes empty directory.
Syntax:
rmdir [options] [directory name]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tkanu025@hp:~$ ls | |
Bond007 avengers ff-series insta oop os | |
tkanu025@hp:~$ rmdir os | |
tkanu025@hp:~$ ls | |
Bond007 avengers ff-series insta oop | |
tkanu025@hp:~$ rmdir insta | |
rmdir: failed to remove 'insta': Directory not empty | |
tkanu025@hp:~$ |
10. rm command
It is used to remove the file from the directory.
Note: the rmdir is to delete folder where as rm is to delete files
Syntax: rm [options] [file name]
Description:
- Deleted file can't be recovered.
- rm can't delete the directory.
- All files can be deleted at once just by using * (asterisk). i.e., rm *
-f ignore non-existent files, and never prompt before
removing.
-i Asks for confirmation before every removal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tkanu025@hp:~$ ls | |
1 Bond007 avengers commands.txt ff-series filename.txt insta main.py oop oop.java | |
tkanu025@hp:~$ rm filename.txt | |
tkanu025@hp:~$ ls | |
1 Bond007 avengers commands.txt ff-series insta main.py oop oop.java | |
tkanu025@hp:~$ rm 1 | |
rm: cannot remove '1': Is a directory | |
tkanu025@hp:~$ rm -i commands.txt | |
rm: remove regular empty file 'commands.txt'? y | |
tkanu025@hp:~$ ls | |
1 Bond007 avengers ff-series insta main.py oop oop.java | |
tkanu025@hp:~$ rm -f oop.java | |
tkanu025@hp:~$ ls | |
1 Bond007 avengers ff-series insta main.py oop | |
tkanu025@hp:~$ |
Comments