Ubuntu is a Linux based operating system and most Linux users are more familiar with the command line interface. In this chapter, we will go through some of the popular command line’s used in Ubuntu.
To invoke the command line, go to the search option and enter the command keyword in the search box.
The search result will give the Terminal option. Double-lick to get the command line as shown in the following screenshot.
The easiest command to start with, is the directory listing command which is used to list the directory contents.
ls –option directoryname
Option − These are the options to be specified with the ls command.
Directoryname − This is the optional directory name that can be specified along with the ls command.
The output will be the listing of the directory contents.
In the following example, we just issue the ls command to list the directory contents.
The directory listing of the current directory will be shown as the output.
Another variant of the ls command is to list the directory, but with more details on each line item. This is shown in the following screenshot with the ls –l command.
To clear the screen, we can use the clear command.
clear
None
The command line screen will be cleared.
To get more information on a command, we can use the ‘man’ command.
man commandname
Commandname − This is the name of the command for which more information is required.
The information on the command will be displayed.
Following is an example of the ‘man’ command. If we issue the ‘man ls’ command, we will get the following output. The output will contain information on the ls command.
We can use the find command to find for files.
find filepattern
Filepattern − This is the pattern used to find for files.
The files based on the file pattern will be displayed.
In this example, we will issue the following command.
find Sample.*
This command will list all the files which start with the word ‘Sample’.
This command is used to display who is the current logged on user.
whoami
None
The name of the current logged on user will be displayed.
In this example, we will issue the following command.
whoami
This command will display the current working directory.
pwd
None
The current working directory will be displayed.
In this example, we will issue the following command.
Pwd