The Linux (actually GNU/Linux), as well as any operating system modern, is perfectly able to offer interaction with the user through graphics, making it can use most of their resources through the mouse. However, at a given moment, the graphical mode can not be available, leaving only the text mode (for the insert of commands). In addition, certain tasks can only be performed by typed commands. To not get lost in any of these situations, it is necessary to know some Linux commands. This is what this area offers the following.
Where and how to type the commands?
If the Linux that you use, enter direct graphics mode to be initialized (which is what happens in the great majority of modern distributions), it is possible to insert commands on the system through a terminal application. This resource is easily localizable in any distribution. The image below, for example, shows a terminal in Ubuntu Linux:
If the computer that you access is not with the graphic mode enabled, it will be possible to type commands directly, simply by if you log in. When the command is entered, it is up to the interpreter commands (also known as shell) to run it. The Linux account with more than one, the most familiar being the bash and the sh.
When a terminal is accessed, a information appears in the field of insertion of commands. It is important to know interpret it. To do this, see the examples below:
Example 1: [root@abbreviationfinder /root]#
Example 2: [wester@rosemary /]$
Note: depending on your distribution and your shell, the command line may have a slightly different format from what is shown in the examples. In Ubuntu Linux, for example, the the second example is in the following form:
wester@rosemary: ~$
In the examples, the word before the @ symbol, which says the name of the user who is using the terminal. The names that appear after the @ would indicate to the computer that is being accessed followed by the directory.
The character that appears at the end indicates that the “power” of the user. If the symbol is #, it means that user has privileges administrator (root). By the other hand, if the symbol is $, it means that this is a the common user, unable to access all of the resources that an administrator accesses. Whatever, it is after the character that the the user can enter the commands.
The basic commands of Linux
Now that you already know how to act in a terminal, go to Linux commands more common. To use them, just type them and press the Enter key on your keyboard. It is important to note that, depending on your Linux distribution, or another command can be unavailable. In addition, some commands only can be run by users with administrator privileges.
The following list shows the commands followed by a brief description:
cal: displays a calendar;
cat file: shows the content of a file. For example, to view the file abbreviationfinder.txt simply type cat abbreviationfinder.txt;
cd directory: opens a directory. For example, to open the folder /mnt, just type cd /mnt. To go to the root directory from any the other type only cd;
chmod: command to change the permissions of files and directories. Learn more in this article about permissions;
clear: deletes all of the contents visible, leaving the command line at the top, as if the terminal would have been accessed;
cp source destination: copies a file or directory to another location. For example, to copy the fileabbreviationfinder.txt with the name abbreviationfinder2.txt for /home, just type cp abbreviationfinder.txt /home/abbreviationfinder2.txt;
date: shows the current date and time;
df: shows the partitions used;
diff file1 file2: indicates the the differences between two files, for example: diff calc.c calc2.c;
du directory: shows the size of a directory;
emacs: opens the emacs text editor;
file file: shows information of a file;
find directory parameter term: the find command serves to locate information. To do this, you must type the command followed directory of search over a parameter (see list below) and the search term. Parameters:
name – search by name
type – search by type
size – search by file size
mtime – search by date of modification
finger user: displays information on the indicated user;
free: shows the amount of memory Available RAM;
halt: turns off the computer;
history: shows the last commands inserted;
id user: shows what the identification number of the specified user in the system;
kill: ends processed in progress. Learn more in the article Processes on Linux;
ls: list the files and directories of the current folder;
lpr file: prints the specified file;
lpq: shows the status of the print queue;
lprm: removes jobs from the print queue;
lynx: opens the internet browser of the same name;
mv source destination: has the same function the cp command, only instead of copy, it moves the file or the directory to the specified destination;
mkdir directory: creates a directory, for example, mkdir abbreviationfinder creates a folder name abbreviationfinder;
passwd: changes your password. For an administrator to change a user’s password, just type passwd followed by the name this;
hp: shows the running processes.
pwd: shows the directory in which you is;
reboot: restarts the system immediately (somewhat recommended, preferable shutdown -r now);
rm file: deletes the specified file;
rmdir directory: deletes the directory specified, since empty;
shutdown: shuts down or restarts the computer, see:
shutdown-r now: restarts the computer
shutdown-h now: turns off the computer
The parameter now it can be changed. For example: type shutdown-r +10 and the system will restart in 10 minutes;
su: go to the user administrator, that is, the root (note that the $ symbol will change to #);
tar -xzvf arquivo.tar.gz: extracts a compressed file in a tar.gz. Learn more in the article Compression and decompression of files with Tar and gzip;
telnet: active service Telnet in a machine. To access this computer from other computers for Telnet, just type telnet machine name or telnet IP. For example: telnet 192.168.0.10. After you open the Telnet, type help to get to know its functions;
top: displays the list of processes, as the memory resources consumed;
uname: shows information and operating system of your computer. Type uname -the for more details;
useradd user: creates a new user account, for example, useradd marvin creates the user marvin;
userdel user: deletes the account of the specified user;
uptime: shows how many hours your computer is connected;
vi: starts the text editor vi. Learn more here;
whereis name: search for the binary the indicated file, useful to know its directory or if it exists on the system;
w: shows the users logged in currently on the computer (useful for servers);
who: shows who is using the system.
Ending
Virtually all of the commands mentioned have parameters that allow enhance your features. For example, if you type the command ls with the parameter -R (ls -R), this will show all the files in the directory, including hidden.
The best way to learn about the additional parameters for each command it is referring to the help information. For this, you can use the feature –help. See the example for the command ls:
ls –help
It is also possible to use the command man (since your content is installed), which generally provides for more detailed information. Pair to use the man for details of the command cp for example, the syntax is:
man cp
If you are using bash, you can apply the command help or info in the same way that the command man:
help cp
info cp
As well as knowing the basic commands of Linux is important, also is to know how to access their help resources, as so you don’t have to memorize the sequences of the extra features. Knowing to use all the features, you certainly will have a good productivity in their tasks in Linux.