Every shell language has its most-used commands. Let’s start building your Bash repertoire by examining the most commonly used commands.
Bash commands
Let’s look at common Bash commands and how to use them.
ls command
ls lists the contents of your current directory or the directory specified in an argument to the command. By itself, it lists the files and directories in the current directory:
BashCopy
ls
Files and directories whose names begin with a period are hidden by default. To include these items in a directory listing, use an -a flag:
BashCopy
ls -a
To get even more information about the files and directories in the current directory, use an -l flag:
BashCopy
ls -l
Here’s some sample output from a directory that contains a handful of JPEGs and PNGs and a subdirectory named gifs:
OutputCopy
-rw-rw-r-- 1 azureuser azureuser 473774 Jun 13 15:38 0001.png
-rw-rw-r-- 1 azureuser azureuser 1557965 Jun 13 14:43 0002.jpg
-rw-rw-r-- 1 azureuser azureuser 473774 Mar 26 09:21 0003.png
-rw-rw-r-- 1 azureuser azureuser 4193680 Jun 13 09:40 0004.jpg
-rw-rw-r-- 1 azureuser azureuser 423325 Jun 10 12:53 0005.jpg
-rw-rw-r-- 1 azureuser azureuser 2278001 Jun 12 04:21 0006.jpg
-rw-rw-r-- 1 azureuser azureuser 1220517 Jun 13 14:44 0007.jpg
drwxrwxr-x 2 azureuser azureuser 4096 Jun 13 20:16 gifs
Each line provides detailed information about the corresponding file or directory. That information includes the permissions assigned to it, its owner, its size in bytes, the last time it was modified, and the file or directory name.
Leave a Reply