Linux Commands Series 2 : ls command
In the previous tutorial, we saw some basic linux commands, like pwd, echo, and ls. Today, I will present ls more in depth, with many handy options. So Let's start :
ls : ls will list all the files in the current directory, one after an other, if we want a long listing format we must provide it with the option -l
2. if you want to include the hidden files (starting with a .), we provide ls with the option -a. One interesting thing about Linux commands is that we can concatenate many parameters after one dash, without providing a dash for each parameter, in this case, we can provide ls with the option a and l, like this :
Notice that ls -al provide more files than ls -l : the dot (.) refers to the directory itself, the two dots (..) refers to the the parent directory, and .config is a hidden file
3. if you don't want . and .. to show, use the -A option instead :
4. list files by extension :
Files are listed by extension, with directories first, then .bak files, then .txt files
5. list files by modification date : ls -t list the file by modification date, from the most recent to the oldest, by column format, starting from left and down, if you want clearer format use ls -tl :
6. Hide certain type of files : if you want to hide files with specific extension , you can use --hide option, say for example you don't want to show backup files with extension .bak , you can use ls --hide = *.bak
7. List all files recuresively, i.e. : those of current directory and its subdirectories
The files are listed recursively, the . means the current directory, then subdir1 directory's files are listed, then those of subdir2
In the next tutorial, I will present you other five handy Linux commands, if you have any question, leave a comment, if you found the post useful, don't forget to share it with your friends.
Happy learning !