Book Image

Learn Linux Quickly

By : Ahmed AlKabary
Book Image

Learn Linux Quickly

By: Ahmed AlKabary

Overview of this book

Linux is one of the most sought-after skills in the IT industry, with jobs involving Linux being increasingly in demand. Linux is by far the most popular operating system deployed in both public and private clouds; it is the processing power behind the majority of IoT and embedded devices. Do you use a mobile device that runs on Android? Even Android is a Linux distribution. This Linux book is a practical guide that lets you explore the power of the Linux command-line interface. Starting with the history of Linux, you'll quickly progress to the Linux filesystem hierarchy and learn a variety of basic Linux commands. You'll then understand how to make use of the extensive Linux documentation and help tools. The book shows you how to manage users and groups and takes you through the process of installing and managing software on Linux systems. As you advance, you'll discover how you can interact with Linux processes and troubleshoot network problems before learning the art of writing bash scripts and automating administrative tasks with Cron jobs. In addition to this, you'll get to create your own Linux commands and analyze various disk management techniques. By the end of this book, you'll have gained the Linux skills required to become an efficient Linux system administrator and be able to manage and work productively on Linux systems.
Table of Contents (24 chapters)

Combining command options

You have learned a lot of different options that you can use with the ls command. Table 4 summarizes all the options we have used so far.

ls option What it does
-l Long and detailed listing of files.
-a List the hidden files.
-d List directories themselves, not their contents.
-t Sort files by modification times.
-u When used with -l, it shows access times instead of modification times. When used with -lt, it will sort by, and show, access times.
-r Will reverse listing order.
-R List subdirectories recursively.

Table 4: Popular ls Command Options

You will often be wanting to use two or more command options at a time. For example, ls -a -l is commonly used to do a long listing for all the files in a directory.

Also, ls -l -a -t -r is a very popular combination because sometimes you would want to see the listing of the files sorted by modification times (oldest first). For that reason, combining the command options is more efficient and so running the ls -latr command:

elliot@ubuntu-linux:~$ ls -latr 
total 120
-rw-r--r-- 1 elliot elliot 0 Apr 11 2010 file2
-rw-r--r-- 1 elliot elliot 807 Dec 26 23:47 .profile
-rw-r--r-- 1 elliot elliot 3771 Dec 26 23:47 .bashrc
drwxr-xr-x 9 root root 4096 Jan 17 04:37 ..
-rw-r--r-- 1 elliot elliot 220 Jan 20 17:23 .bash_logout
drwxr-xr-x 6 elliot elliot 4096 Jan 25 22:13 Desktop
-rw-r--r-- 1 elliot elliot 0 Jan 25 23:08 file1
-rw-r--r-- 1 elliot elliot 0 Jan 25 23:27 file3
drwxr-xr-x 3 elliot elliot 4096 Jan 25 23:52 dir1
-rw------- 1 elliot elliot 3152 Jan 26 00:01 .bash_history
drwxr-xr-x 17 elliot elliot 4096 Jan 30 23:32 .

Will yield the same result as running the ls -l -a -t -r command:

elliot@ubuntu-linux:~$ ls -l -a -t -r 
total 120
-rw-r--r-- 1 elliot elliot 0 Apr 11 2010 file2
-rw-r--r-- 1 elliot elliot 807 Dec 26 23:47 .profile
-rw-r--r-- 1 elliot elliot 3771 Dec 26 23:47 .bashrc
drwxr-xr-x 9 root root 4096 Jan 17 04:37 ..
-rw-r--r-- 1 elliot elliot 220 Jan 20 17:23 .bash_logout
drwxr-xr-x 6 elliot elliot 4096 Jan 25 22:13 Desktop
-rw-r--r-- 1 elliot elliot 0 Jan 25 23:08 file1
-rw-r--r-- 1 elliot elliot 0 Jan 25 23:27 file3
drwxr-xr-x 3 elliot elliot 4096 Jan 25 23:52 dir1
-rw------- 1 elliot elliot 3152 Jan 26 00:01 .bash_history
drwxr-xr-x 17 elliot elliot 4096 Jan 30 23:32 .

Before this chapter comes to an end, I want to show you a pretty cool tip. First, let's create a directory named averylongdirectoryname:

elliot@ubuntu-linux:~$ mkdir averylongdirectoryname 
elliot@ubuntu-linux:~$ ls -ld averylongdirectoryname
drwxr-xr-x 2 elliot elliot 4096 Mar 2 12:57 averylongdirectoryname

Tab Completion is one of the most useful features in the Linux command line. You can use this to feature to let the shell automatically complete (suggest) command names and file paths. To demonstrate, type (don't run) the following text on your terminal:

elliot@ubuntu-linux:~$ cd ave

Now press the Tab key on your keyboard, and the shell will automatically complete the directory name for you:

elliot@ubuntu-linux:~$ cd averylongdirectoryname/

Pretty cool! Alright, this takes us to the end of this chapter, and it's time for you to do the lovely knowledge check.