Linux console commands. Basic Linux and Unix console commands Commands in the linux console

In all operating systems, including Linux, the term "command" means either a command-line utility or a specific feature built into the system's command shell. However, for the users themselves, this distinction does not really matter. After all, both Linux terminal commands are invoked in the same way. You type a word into your terminal emulator and get the output of the command.

I have already written about Linux terminal commands, but then I touched on only a few of the most interesting, most useful commands, relying on the fact that the user is already quite familiar with the capabilities of the terminal. But we need to make one more article, designed for beginners, those who are just taking their first steps in mastering Linux.

And here she is. Its purpose is to collect the basic simple and complex Linux commands that every user should know in order to most effectively manage their system. For the convenience of remembering the command options, I added the words from which they came from in brackets - it's much easier, I've tested it myself.

This does not mean that I will list all the commands - I will try to cover all the most useful things that can come in handy in everyday life. To make it easier to read, we divide this list into categories of commands by purpose. Most of the utilities discussed here do not require additional installation, they will be pre-installed in any Linux distribution, and if they are not, then they are easy to find in the official repositories.

1.ls

A utility for viewing the contents of directories. By default, it shows the current directory. If you specify a path in the parameters, it will list the contents of the target directory. Useful options -l ( L ist) and -a ( A ll). The former formats the output as a list with more detailed information, while the latter enables the display of hidden files.

2 cat

Prints the contents of the file passed as a parameter to standard output. If you transfer multiple files, the command will merge them. You can also redirect the output to another file using the ">" symbol. If you want to print only a certain number of lines, use the -n option ( N umber).

3.cd

Allows you to change from the current directory to the specified one. If run without parameters, it returns to the home directory. A call with two dots returns one level up from the current directory. A dash call (cd -) returns to the previous directory.

4.pwd

Prints the current directory to the screen. This can be useful if your Linux command line does not display this information. This command will be required in Bash programming, where a script is executed to get a link to a directory.

5.mkdir

Creation of new directories. The most convenient option is -p ( P arents) allows you to create an entire subdirectory structure with a single command, even if they don't exist yet.

6. file

Shows the file type. On Linux, files do not always need to have extensions in order to work with them. Therefore, it is sometimes difficult for the user to determine what kind of file is in front of him. This little utility solves the problem.

7.cp

Copying files and directories. It does not copy directories recursively by default (i.e. all subdirectories and all files in subdirectories), so be sure to add the -r option ( R ecursive) or -a ( A rchive). The latter includes a mode to preserve attributes, owner, and timestamp in addition to recursive copying.

8.mv

Moving or renaming files and directories. It is noteworthy that in Linux this is the same operation. Renaming is moving a file to the same folder with a different name.

9.rm

Deletes files and folders. A very useful Linux command: with it, you can clean up all the mess. If recursive deletion is required, use the -r option. However, be careful: of course, in order to damage the system, you will need to seriously try, but you can delete your own important files. Rm does not delete files to the recycle bin, from which everything can then be restored, but completely erases. Operator actions rm irreversible. Believe me, your excuses in the spirit of "rm ate my term paper" will not be of interest to anyone.

10 ln

Creates hard or symbolic links to files. Symbolic or soft links are something similar to shortcuts in Windows. They provide a convenient way to access a specific file. Symbolic links point to a file but do not have any metadata. Hard links, unlike symbolic links, point to the physical address of the disk area where the file data is stored.

11.chmod

Changes the permissions on a file. These are read, write and execute. Each user can change the permissions for their files.

12. chown

Changes the owner of a file. Only the superuser can change owners. To change recursively, use the -R option.

13. find

Search in the file system, files and folders. This is a very flexible and powerful Linux command, not only because of its snooping abilities, but also because of the ability to execute arbitrary commands on found files.

14. locate

Unlike find, the locate command searches the updatedb database for filename patterns. This database contains a snapshot of the file system, which makes searching very fast. But this lookup is unreliable because you can't be sure nothing has changed since the last snapshot.

15.du

Shows the size of a file or directory. Most useful options: -h ( H uman) that converts file sizes to an easily readable format, -s ( S ummarize), which outputs the minimum data, and -d ( D epth) that sets the depth of directory recursion.

16.df

Disk space analyzer. By default, the output is quite detailed: all file systems are listed, their size, the amount of used and free space. For convenience, there is the -h option, which makes the dimensions easy to read.

17.dd

As the official manual says, this is a terminal command to copy and convert files. Not a very clear description, but that's all dd does. You give it a source file, a destination, and a couple of additional options. It then makes a copy of one file into another. You can set the exact size of the data to be written or copied. The utility works with all devices. For example, if you want to overwrite the hard drive with zeros from /dev/zero, you can do so. It is also often used to create LiveUSB or hybrid ISO images.

18mount / umount

These are Linux console commands for mounting and unmounting Linux filesystems. You can connect everything from USB drives to ISO images. And only the superuser has permissions to do so.

Linux console commands for working with text

19. more / less

These are two simple terminal commands for viewing long texts that do not fit on one screen. Imagine a very long command output. Or you called cat to view a file and it took a few seconds for your terminal emulator to scroll through all the text. If your terminal does not support scrolling, you can do this with less. Less is newer than more and supports more options, so there is no reason to use more.

20 head / tail

Another pair, but here each team has its own scope. Head prints the first few lines from the file (head), and tail prints the last few lines (tail). By default, each utility outputs ten lines. But this can be changed with the -n option. Another useful option is -f, which is short for f ollow (follow). The utility constantly displays changes in the file on the screen. For example, if you want to keep track of a log file, instead of constantly opening and closing it, use the tail -nf command.

21. grep

Grep, like other Linux tools, does one thing, but it does it well: it searches for text in a pattern. It accepts standard input by default, but you can search in files. The pattern can be a string or a regular expression. It can output both matching and non-matching lines and their context. Any time you run a command that produces a lot of information, you don't have to parse everything by hand - let grep do its magic.

22.sort

Sort lines of text according to various criteria. Most useful options: -n ( N umeric), by numeric value, and -r ( R everse) which reverses the output. This can be useful for sorting the output of du. For example, if you want to sort files by size, just combine these commands.

23.wc

Linux command line utility for counting the number of words, lines, bytes and characters.

24.diff

Shows the differences between two files in a line by line comparison. Moreover, only lines in which differences are found are displayed. Changed lines are marked with "c", deleted ones with "d", and new ones with "a".

By the way, I have prepared another detailed article, which describes exactly using the terminal.

Linux commands for managing processes

25.kill/xkill/pkill/killall

Used to terminate processes. But they take different parameters to identify processes. Kill needs the PID of the process, xkill just clicks on the window to close it, killall and pkill take the name of the process. Use the one that is comfortable in a particular situation.

26.ps/pgrep

As already mentioned, in order to kill a process, you need its ID. One way to get it is with the ps utility, which prints information about running processes. The output is very long by default, so use the -e option to see information about a specific process. This is only a snapshot of the state at the time of the call and the information will not be updated. The ps command with the aux switch displays complete information about the processes. Pgrep works like this: you give the process a name, and the utility displays its ID.

27.top/htop

Both commands are similar, both display processes and can be used as console system monitors. I recommend installing htop if your distribution doesn't come with it by default, as it's an improved version of top. You can not only view, but also control processes through its interactive interface.

28th time

Process execution time. This is a stopwatch for running the program. Useful if you're wondering how far your implementation of the algorithm lags behind the standard. But despite this name, it will not tell you the current time, use the date command for this.

Linux User Environment Commands

29. su / sudo

Su and sudo are two ways to accomplish the same task: run a program as a different user. Depending on your distribution, you are probably using one or the other. But both work. The difference is that su switches you to a different user, while sudo only executes the command as that user. Therefore, using sudo will be the safest way to work.

30th date

Unlike time, it does exactly what you expect it to do: it prints the date and time to standard output. It can be formatted depending on your needs: output year, month, day, set 12 or 24 hour format, get nanoseconds or week number. For example, date +"%j %V", will output the day of the year and the week number in ISO format.

31. alias

The command creates synonyms for other Linux commands. That is, you can make new commands or groups of commands, as well as rename existing ones. This is very handy for shortening long commands you use often, or making more descriptive names for commands you use infrequently and can't remember.

32. uname

Displays some basic information about the system. Without options, it won't show anything useful other than the Linux line, but if you specify the -a option ( A ll), you can get information about the kernel, hostname and processor architecture.

33. uptime

Tells you the system uptime. Not very significant information, but may be useful for random calculations or just out of curiosity to find out how long ago the server was rebooted.

34. sleep

You are probably wondering how you can use it. Even aside from Bash scripting, it has its advantages. For example, if you want to turn off the computer after a certain period of time or use it as an impromptu alarm.

Linux Commands for User Management

35.useradd/userdel/usermod

These Linux console commands allow you to add, remove, and modify user accounts. Chances are you won't be using them very often. Especially if this is a home computer and you are the only user. You can also manage users using the graphical interface, but it's better to know about these commands just in case.

36.passwd

This command allows you to change the user account password. As a superuser, you can reset the passwords of all users, even though you cannot see them. Good security practice is to change your password frequently.

Linux commands for viewing documentation

37. man / whatis

The man command opens the manual for a specific command. There are man pages for all the basic Linux commands. Whatis shows which sections of the manuals are available for a given command.

38. whereis

Shows the full path to the program's executable file. It can also show the path to the sources, if they are in the system.

Linux Commands for Network Management

39.ip

If the list of Linux commands for network management seems too short to you, most likely you are not familiar with the ip utility. The net-tools package contains many other utilities: ipconfig, netstat, and other obsolete ones like iproute2. All this is replaced by one utility - ip. You can think of it as a Swiss army knife for networking or as an incomprehensible mass, but in any case, it is the future. Just deal with it.


The Linux operating system has long established itself as stable and friendly to its users. He patiently bears both the mistakes of programmers and the inept handling of a beginner. And as it has already become customary in OS Linux, there is a wide choice of tools for solving any problem.

This section will focus on console commands. A user who has had time to largely get used to convenient window managers that allow you to open a file or run a program with one click of the mouse may find this something wild and quite possibly very inconvenient. But one has only to try, as all fears will dissipate like a morning mist in the rays of the rising sun.

If you have not worked in the console yet, then you may be interested to know that with the help of simple commands you can install a new package and immediately clear the cache of the Synaptic program (sudo apt-get clean), connect a disk, or even dismantle everything (sudo mount -a) , or maybe even arrange a video card test (glxgears -printfps) if there is a desire. You may need to find something in a directory and its subdirectories while in console mode and make it readable for others (# find /myotherdir/ -type f -exec chmod a-x,u+w () \;).

Simple and useful commands will surely come in handy for you. Of course, the goal here is not to tell you about all the existing Linux commands, and all of them are unlikely to ever be needed. The list below contains only the most basic and necessary of them. To obtain comprehensive information about a particular command and all possible options for its launch, you will need to use the corresponding page of the online man or info manual.

ag[ options ] [archiver ] [ names of archive files ] - a program that allows you to work with archive files of various types.

bad blocks[ options ] [ device ] - search for bad physical sectors of the disk.

bzip2[ options ] [ filenames ] - utility for compressing files.

cal[ options ] [ month [ year ] ] - this command displays the calendar. By default, it will display the current month's calendar. For example, the command: cal -3 - will display a calendar for 3 months.

cd / directory- the command allows you to change the current directory. Example: cd ~/ quickly navigates to the user's home directory.

chmod[ options ] [ file mode ] - this command allows the superuser or user - the owner of a file to change its attributes. You can use octal or symbolic notation to designate attributes. For example, we needed to make the file executable, for this we can use the sudo chmod +x [file] command or by running the chmod 777 -cR /home/somefolder command, you can set the rights to the entire folder and all its contents (the -R switch is recursive), you can and do not use the combination of -cR options, the -c switch prints information to the console so you can make sure that the permissions have definitely been changed.

chown[ options ] [ file ] - running this command as a superuser will allow you to change the owner or group of owners of a file.

clear- clearing the terminal window.

cmp[ parameters ] [ file1 ] [ file2 ] - the command launches a utility for byte-by-byte comparison of two files.

comm[ options ] [ file1 ] [ file2 ] - this command allows you to compare two files line by line.

compress[ options ] [ filename ] - command to reduce the size of the specified file.

Wed[options] [source] - this program is used to copy files and directories.
Example: cp /home/filename to /Desktop/foldername

date [ options ] - this command is needed to display and change the system date and time.

diff[ options ] [ file1 ] [ file2 ] is another utility for comparing two files. After the comparison, it displays the lines where differences were found.

diff3[ options ] [ file1 ] [ file2 ] [ file3 ] - the same utility that can compare three files.

dir- displaying the list of files in this directory.

e2fsck[ options ] [ device ] - utility for checking and repairing damaged ext2 partitions.

eject- A utility for ejecting CDs. The same command can be used to adjust the speed of a CD-ROM, for this we execute the eject -x [speed] command, which happens, for example, when listening to music, when an extra source of noise only distracts. In other matters, there is another command hdparm -E8 /dev/cdrom for these purposes. But there are certain inconveniences in its use, we need to have access to the root account, and on some drives the disk still accelerates over time and we have to re-execute the command. In general, when working with a CD-ROM, other commands can be used. For example, lsof +d /media/cdrom - allows you to get information about what prevents the ejection of the CD, or if for some reason we do not want to deal with it, then the disk can be ejected forcibly with the command: umount -l /media/cdrom && eject It's also easy to work with disk images, for example with the command: sudo mount -o loop -t iso9660 [what] [where] You can easily mount an ISO disk image.

echo[what] >> [where] // add [what] to the end of the file [where] For example, if you write one ">", the file will be overwritten.

fdformat[ options ] [ device ] - low-level formatting of the floppy disk.

find[ path ] [ options ] - a command to search for files that match the given parameters.

fmt[ options ] [ file ] - utility for simple text processing.

free[ parameters ] - display information about the available free RAM.

fuser[ options ] [ file ] - this command displays all processes using the given file.

gnome-terminal- creates a working terminal in the Gnome environment

groups[ options ] - display the groups the user is a member of.

gunzip[ file ] - decompression of files compressed with the gzip utility.

gzip[ parameters ] [ file ] - utility for archiving. Creates archive files with .GZ extension.

halt[ options ] - shutdown the computer.

help[ options ] - as the name implies, this command is responsible for displaying the help system for built-in shell commands. If entered without additional parameters, the user will see a complete list of all built-in commands.

history[ parameters ] - list of executed commands.

id[ options ] [ user ] - the command shows the ID of the current user and the group to which he belongs.

info- Displays an online help manual, alternative to man.

jobs- this command shows the processes running in the background.

kill[ parameters ] [ PID ] - the command sends a termination signal to a particular process. It can be used to terminate a hung application.

killall[ parameters ] - termination of all processes that match the specified parameters.

links- launching the Links text web browser.

Is[ options ] - command to display information about all files in the directory. More detailed information can be obtained by using additional options, for example, using the ls command with the -la option ( ls-la) file attributes will be displayed (w - Write, r - Read, x - Execute).

lynx- Launches the Lynx text web browser.

man[ options ] - online reference manual man. If we also specify man in the options, we will get help on using this manual.

mc- start file manager Midnight Commander.

mformat[ options ] [ drive ] - formatting a floppy disk for MS-DOS. Currently a rather rarely used command.

mkbootdisk- Creation of an emergency boot diskette.

mkdir[ options ] [ path ] - create a new directory. Example: mkdir /Desktop/name_of_directory_to be created

mount[ file system ] - mount any of the supported Linux file systems.

mpartition- creating an MS-DOS partition.

mv[options] [source] [destination] - command to move files and directories.

nano- launching the nano console text editor. Please note that when executing a command, for example pico, you may not achieve what you want if you do not have the latter installed on your system, this also applies to other packages such as nano or vi.

passwd[ user ] - a command that allows the user to change his password, and the superuser - to change the password of any user registered in the system.

pidof[ options ] [ applications ] - this command displays the identifier (PID) of a particular process. Knowing the PID, a hung process can be killed using the kill command.

power off[ options ] - command to turn off the computer. An analogue of the halt command.

pwd- the command shows the path to the current directory.

quota[ options ] - display the amount of available free space in the partition.

reboot- this command, unlike halt and poweroff, does not disable, but reboots the system.

resize2fs[ options ] device [ new size ] - change the size of the ext2 file system.

reset- clears the terminal window.

rm[ options ] [ file or directory ] - using this command, you can delete a file or directory.

rpm[ options ] is a widely used binary package format. Used to install new programs or update existing ones.

sleep[time] [options] - pause for a specified amount of time. Allows you to delay the execution of a process. For example, it might look like this sleep 15 && reboot , which will result in a reboot after the specified time interval.

sndconfig- launching a utility for configuring sound in Linux. If the sound card was not recognized during the installation process, you can use this utility.

tar[ options ] - command for working with tar archives. By specifying the necessary parameters, depending on your goals, you can create an archive, for example, from a list of files, listing the necessary files separated by a space, for example: tar -cvf homefiles.tar file1 file2 file3 or unpack files from the selected archive tar -xvf archive_name.tar

top- An interactive list of current processes sorted by CPU usage. But in our opinion, the htop package is more convenient in this regard, respectively, the htop call command.

touch- creates a text file. Example: touch /Desktop/Somefolder/Newfile

umount[ options ] - this command disables filesystems from Linux. Recall that they are connected using the mount command.

uname-a - display information about the version of the operating system.

uncompress[ options ] [ file ] - decompression of files compressed with the compress command.

unexpand[ options ] [ file ] - convert spaces to tabs in the given file.

unzip[ options ] [ zipped file ] - using this command, you can unzip a file compressed by the zip archiver.

users- display of users currently connected to the system.

vi- launching the vi console text editor.

w[ options ] [ user ] - displays the users currently connected to the system and the processes they run.

wc[ options ] [ file ] - this command shows the number of bytes and lines in the specified file.

which[ application ] - the command shows the full path to the executable file of a particular application.

zip[ options ] [ file ] is a widely used utility for archiving files.

That, perhaps, is all. I tried to talk about the main and necessary commands. Since it was not my goal to describe all the commands in detail, and now you don’t need it, because you can always use the corresponding page of the online man or info manual. How to do it?

The command line capabilities are truly impressive. I sincerely wish you success in their development.

Starting to learn the Linux console, you can not do without knowing the console commands.

This note lists the main Linux console commands available both from the terminal and via ssh:
su, sudo, whoami, fsck, uptime, who, w, df, du, ifconfig, ping, traceroute, mtr, whois, ps, top, kill, killall, man, passwd, ls, pwd, mkdir, rmdir, rm, mv, cat, less, more, chmod, chown, tar, wget, find, locate, history, reboot, halt, shutdown

su log in as peleh without ending the current session.

the invitation character for users looks like $, and for the root superuser it looks like #.

Usually the command su used for temporary superuser login to perform administrative work.

sudo command

sudo allows users to execute commands as root or other users. The rules used by sudo to decide whether to grant access are in the file /etc/sudoers.

whoami team

whoami- display the name of the user who is authorized in the system

fsck command

fsck is a UNIX command that checks and fixes errors in the file system. After running the command, you must confirm (y) or not confirm (n) the correction of a particular error. To automatically check and fix errors, you need to run the command with the ‘-y’ switch: fsck -y

uptime command

uptime shows current time, uptime after boot, number of current users and load for the last 1, 5 and 15 minutes.

who command

who- show a list of users in the system

w command

w- show information about users currently working on the server and their processes, as well as the average server load for the last 1, 5 and 15 minutes ( uptime + who).

df command

df(abbreviation for disk free) - show a list of all file systems by device name, reports their size, used and free space and mount points. It is convenient to use with the -h switch (the size is displayed in Gb):

du command

du- show the size of a single file:

ifconfig command

ifconfig— show network settings (interfaces):

ping command

ping- a utility for checking connections in networks based on TCP / IP:

traceroute command

traceroute— determine the data route in TCP/IP networks:

mtr command

mtr ya.ru - show the route of data on the Internet and the percentage of losses, constantly updating the data:

whois command

whois— show information about the domain (data about the registrar, domain renewal period, name servers…):

ps command

ps- list your current active processes

top command

top- show all running processes

kill command

kill pid - kill process with id pid

killall command

killall ispmgr - kill all processes named ispmgr

man command

man passwd - Display help for the passwd command

passwd command

passwd testuser - change the password for the testuser user. By default, the passwd command without specifying a specific user will change the password for a user who is authorized in the system.

ls command

ls- a list of files and directories (with the "-la" key - a list with hidden files):

pwd command - current directory

pwd- display the full path from the root directory to the current working directory (shows the directory you are in):

mkdir command

mkdir folder – create a directory/directory folder

rmdir command

rmdir- delete a directory from the file system. Removing a directory and its contents can also be done with the rm -rf command (the -r option for directories).

rm command

rm file - delete file file with confirmation

rm file * - delete all files that begin with the characters file with confirmation:

mv command

mv(from English move) - used to move or rename files or directories:

1 - rename folder folder to folder00:

2 - moving the file to the directory:

cat command

cat> file - send standard input to file (i.e. create a file with the necessary content):

To complete the entry of information into this file, you must, as usual, press the key combination .

cat file - show the contents of the file file:

cat file file1 > file22 - create file file22 and write data from files file and file1 into it:

less, more command

You can also view the contents of a file with the command less or more.

chmod command

chmod- change access rights to a file or directory (for directories, 751(-rwxr-xr-x) is often used, and for files - 644(-rw-rw-r—)), where

4 - reading (r)
2 - record (w)
1 - execution (x):

chown command

chown- change the owner of the file

tar command

tar file.tar file - zip the file file and name it file.tar:

where the -c (create) option is to create. Team tar-xpf folder00.tar unzips the archive into the current directory while maintaining file permissions.

wget command

wget— copy the file to the server over the network:

find command

find- file search:

locate command

locate- file search:

history command

history- show command history (you can specify the number of lines to view):

reboot command

reboot- restart the server

halt command

halt- shut down the server

shutdown command

shutdown— shutdown or restart the server (depending on options)

Linux console commands, or as they say, the command line, is a kind of intermediate link between the user and the computer itself. In order for the machine to fulfill your order, it must be given the appropriate command. Initially, this is exactly how the relationship between a person and a computer took place, but a little later, an additional mouse tool appeared, which greatly simplified the entire process of information exchange and made it more accessible to all users. Nevertheless, the console, and today, remains a powerful and sometimes very convenient tool for performing all kinds of actions.

In general, there are a great many console utilities, but here we will briefly, as an example, consider only two of them, but they are very important and often used. Utility apt-get designed to work with software packages. For those who do not recognize the console at all, they can use the wonderful graphical shell for apt-get, entitled Synaptic(available in the official repository).

How to use the utility?

//main formula

sudo apt-get command

//as an example, update all packages

sudo apt-get upgrade

Basic apt-get commands for working with packages.

apt-get update //update inf. about packages from repositories
apt-get upgrade //update all packages
apt-get dist-upgrade //updating the system as a whole
apt-get clean //cleans lok. storage other than cache files
apt-get autoclean //same as clean, with removed. cache files
apt-get check //updates the cache and check. unsatisfactory dependencies
apt-get autoremove //delete previously downloaded but unnecessary packages
apt-get remove //remove the package with save. config. files
apt-get-purge //remove the package with all dependencies
apt-get install //package installation
apt-get build-dep //set. everything to build source packages
apt-get source //download source packages

Options:

-h, --help //reference
-q, --quiet //hide progress bar
-qq //do not show anything but errors
-d, --download-only //only get packets and exit
-s, --simulate //run event simulation
-y, --yes //autom. answer "Yes" to all questions
--reinstall //reinstall packages
-f, --fix-broken //fix broken dependencies
-m, --ignore-missing //ignore missing packages
-u, --show-upgraded //show updated packages
--no-upgrade //do not update packages
-b, --compile, --build //build package after receiving
-D //on removal, remove dependent components
-V // verbosely show package version numbers
--no-remove //if packages are marked. to removed, then apt-get off
--force-yes //forced execution of the specified operation

Funny.

apt-getmoo

Must see a cow that asks: "Did you moo today?"

aptitude utility.

Consider another very good utility called " aptitude", in fact it is the same as " apt-get", but it is considered better, and also has a pseudo-graphical interface. The principle of operation is exactly the same, only instead of " apt-get", you need to enter a value " aptitude". First, install the utility itself:

sudo apt-get aptitude

Now if you type: aptitude, then you will be taken to the program interface.

Let's look at some commands:

// Install the package.

sudo aptitude package1 package2 package3

As you can see, you can install an unlimited number of packages at once. No matter how many you install aptitude will automatically resolve all dependencies, you will only have to agree (y) and press (enter). Also, by analogy, you can remove packages:

sudo aptitude remove packagename1
or
sudo aptitude purge packagename1

The first command removes only the files of the package without touching the settings, the second one completely removes everything. You can see the description of the package like this:

aptitude show packagename

In general, this utility is an absolute analogue of " apt-get", but when installing and removing packages, it is better to use it than " apt-get". Anyway, on the official website ubuntu give such recommendations.

Other console commands

List of commands related to information.

hostname // network name of the machine
whoami //name of the current user
uname-m //show machine architecture
uname -r //kernel version
sudo dmidecode -q //inform. about the device. providing a system
cat /proc/cpuinfo // processor information
cat /proc/interrupts //interrupts
cat /proc/meminfo //all memory information
cat /proc/swaps //all information about swap
cat /proc/version //kernel version and other information
cat /proc/net/dev //network interfaces and statistics
cat /proc/mounts // mounted devices
cat /proc/partitions //available sections
cat /proc/modules //loaded kernel modules
lspci-tv //PCI devices
lsusb-tv //USB devices
date //The current date
cal //calendar and current month
cal 2012 //shows the whole year 201

Commands related to the reboot and shutdown processes.

shutdown -h now //shut down the system
init 0 //shut down the system
0 //shut down the system
shutdown -h hours:minutes & //schedule system shutdown
shutdown -c //cancel scheduled shutdown
shutdown -r now //reboot the system
reboot //reboot the system
logout //end session

File operations and more...

cd /home // change to home directory
cd.. //go one level up
cd ../.. //go up 2 levels
cd- //move to the previous directory
pwd //show the path to the current directory
ls
ls -F //show files and directories
ls-l //show. details about files, directories
ls-a //show hidden files
mkdir dir1 //create a directory named dir1
mkdir dir1 dir2 //create directories dir1 and dir2
mkdir -p /tmp/dir1/dir2 //create a directory at the specified location
rm -f file1 //delete file with name file1
rmdir dir1 //remove the directory with the name dir1
rm -rf dir1 //remove directory dir1 and all its contents
rm -rf dir1 dir2 //remove directories dir1\dir2 and content
mv dir1 new_dir //rename / move directory
cp //copying files/folders
ln-s //create symbolic link
chmod //assigning file permissions

Search for files and directories.

Forgot where you saved it? No problem! Everything is in the console.

find / -name file1 //search for files, dir. beginning With /
find / -user user1 //search for files, direct. Withuser1
find /home/user1 -name \*.bin //search for files .bin in / home/ user1
find /usr/bin -type f -atime +100 // claim. bin. files, random 100 days
find /usr/bin -type f -mtime -10 // claim. create/edit files in 10 days
find / -name \*.deb -exec chmod 755 "()" \; // claim. files ( .deb) and change. rights
locate \*.ps //find files with extension.ps
whereis halt //show the path to the programhalt
which halt //show. full path to the program.halt

At first glance, all this may look somewhat intimidating, but this is only at first glance. Do not immediately panic and immediately return to Windows(y). Modern distributions as well ubuntu in particular, it quite allows you to do without the command line. However, the command line, in some cases, is much more convenient than the graphical interface. Also, it is not necessary to memorize all these commands, it will be enough to create a text file, copy all the contents into it and keep it nearby, like a cheat sheet, which you can use if necessary.

Of course, this is far from all that concerns the topic of the command line and the commands themselves, if someone is really interested in this, I can advise you to go to the following link, there you can find and download a lot of things, the only question is whether it's all for you. In general, I doubt that today there is at least one person in the whole world who would know all the existing console commands by heart (maybe I'm wrong).

Linux Command References: http://books.tr200.ru/v.php?id=278389

/usr/bin/lsb_release-ircd # Find out the version of the Linux distribution;

uname-a # Show Linux kernel version;

uname-m # Display computer architecture;

hostname # Show the network name of the computer;

uptime # Operating time of the system without rebooting and shutting down;

shutdown # Shutdown\reboot. Examples:
- shutdown -r now # Reboot;
-shutdown -h 20:00 # Power off at 20:00;
-shutdown -h now # Shutdown;

init 0 # Shutdown;

halt # Shutdown;
logout # Log out;# Shows the OS boot log file;
cat /proc/cpuinfo # Show full information about the processor model (frequency, supported instructions, etc.);
cat /proc/meminfo # Show extended information about the occupied RAM;

lshal # Show a list of all devices and their parameters;
lspci-tv # Show detected PCI devices;
lsusb-tv # Show detected USB devices;
lsmod # List of all modules loaded into the kernel;
modprobe # Loading modules into the kernel, example:# An example of changing the root environment to /mnt: chroot /mnt . After that, the root partition mounted to /mnt will be used as a native one;
ldd # List of libraries required for a particular program. List libraries needed for ssh to work: ldd /usr/bin/ssh ;
whereis # Shows the location of binaries, source codes, and manuals related to a particular file. Example: whereis halt ;
crontab # Provides the ability to perform certain tasks on a schedule. More details at the link cron ;

swap off # Disable swap partitions. Disable swap (data is moved to RAM): swapoff -a ;

swapon # Enabling swap partitions. Enable swap: swapon-a ;

date # View and change date\time. Examples:

- date # Shows the current date and time;

- date 041217002007.00 # Set system date and time. Format: MMDDHHmmYYYY.SS;

File operations

pwd # Displays the current path;
ls # Lists files and directories. An example of outputting a formatted list of all files and directories, including hidden ones: ls -laX ;
cd # Navigate through directories. Examples:
- cd # Change to home directory;
- cd /home # Example of moving to /home;
- cd.. # Move to a directory one level higher;
- cd ~user # Change to the user's home directory user ;
touch # Create an empty file if not. Example: touch test.txt ;
rm # Delete. Examples:
- rm test.txt # Deleting a file;
- rm -rf temp # Deleting the temp directory with attached files;
cp # Copy. Examples:
- cp test.txt /home/test.txt # Copies test.txt from the current directory to /home ;
- cp -la /dir1 /dir2 # Copy directories;
ln # Create a symbolic link. Example: ln -s /var/test.txt /home/test.txt - create a symbolic link to the /var/test.txt file in the /home directory;
mkdir # Create a directory. Example: mkdir temp ;
rmdir # Delete directory. Example: rmdir temp ;
mv # Move\Rename. An example of renaming a directory: mv /dir1 /dir2 (similarly with files);
locate # Search. An example of searching everywhere for all files named test.txt: locate test.txt ;
find # Search. Examples:
-find /home/it -name test.txt # Find files and directories named test.txt in /home/it and sub;
- find /home/it -name "*.txt" # Find all files and directories in /home/it and subdirectories whose names end in ".txt";
- find /usr/bin -type f -atime +100 # Find all files in "/usr/bin" last accessed more than 100 days;
-find /usr/bin -type f -mtime -10 # Find all files in "/usr/bin" created or modified within the last 10 days;
stat # Display all available information about the specified file. Example: stattest.txt ;
file # Specifies the file type. Example: file test.txt ;
chmod # Access rights, more details at the link chmod ;
chown # Changes the owner of a file, example: chown www:www test.txt ;
mc # File manager ;

Archiving

tar - archiver. Examples:
-tar cf test.tar /home/test.txt # Create a tar archive named test.tar containing /home/test.txt;
- tar czf test.tar.gz /home/test.txt # Create a Gzip-compressed tar archive named test.tar.gz;
-tar cjf test.tar.bz2 /home/test.txt # Create a tar archive with Bzip2 compression named test.tar.bz;
-tar xf test.tar # Unpack the test.tar archive into the current folder;
- tar xzf test.tar.gz # Unpack the tar archive with Gzip;
- tar xjf test.tar.bz # Unpack tar archive with Bzip2;

Process management

top # Process Manager;
ps # Shows processes. Examples:

- ps axjf# View all running processes;

- ps-eF # List of processes with full start line;
- ps -U user # List of tasks generated by the user user;
pgrep # Search for processes. Show the PID of the sshd process: pgrep -l sshd ;
lsof #lsof /home Shows a list of processes that are using /home;

fuser-m # Find out which process is occupying the device. Example: fuser -m /mnt ;
kill # Kills the process. Examples:

- kill 4712 "Kill" the process with PID 4712:;

- kill -9 4712 # Forcefully terminates the specified process (execute if it does not help kill 4712 );

killall # Kill processes by name. Examples:

- killall x-www-browser # "Kill" x-www-browser processes ;

- killall -u user # Terminate processes spawned by user user;
nice # Allows you to display or set the task priority. Examples:

- nice-4 mc # Run mc with priority = current+4 ;

renice # Change process priority. Examples:
- renice 4 -p 11597 # Set the priority value for the mc process (PID=11597) to 4;

RAM

free # Information about the state of the memory. free-m - show the state of RAM in megabytes;
dmidecode # Information about the hardware. Information about the number of RAM slots, and inserted modules: dmidecode --type 17 . Read more about dmidecode here dmidecode ;

HDD

du # Information about the size of the directory. du -sh /home/it/ displays the size of the /home/it/ directory;
fdisk # Information about hard disk partitions. Information about all connected hard drives and removable drives: fdisk -l . More: fdisk ;
blkid # Displays the UUID of all available storage media in the system;
df # Shows the amount of free space on partitions. Example: df-h ;
mount # Mount. Examples:
- mount # Shows complete information about mounted devices;
-mount /dev/sda1 /mnt # Mounts partition /dev/sda1 to mount point /mnt;
-umount /mnt # Unmount partition from mount point /mnt;
bad blocks # Check for bad blocks. badblocks -v /dev/sda1 check the sda1 partition for bad blocks;
fsck # Checking the file system. fsck /dev/sda1 - check/restore the integrity of the linux-file system of the sda1 partition;
mkfs # Formatting, more details at the link mkfs ;
smartctl # SMART check. smartctl -A /dev/hda - control of the state of the hard disk /dev/hda via SMART, more details at the link smart ;

hdparm # Information about hard drives, Examples:
- hdparm -I /dev/sda # Disk info /dev/sda ;
- hdparm -tT /dev/sda # Shows hard drive performance;

Net

ping # Ping. Ping ya.ru and display the result: ping ya.ru ;
ifconfig # Network setup utility. Examples:
-ifconfig # Show parameters of all active network interfaces;
-ifconfig -a # Show all network interfaces;
-ifconfig eth0 up # Start network interface eth0;
- ifconfig eth0 down # Disable network interface eth0;
-ifconfig eth0 hw ether 00:01:02:03:04:05 # Change MAC address;
-ifconfig eth0 192.168.1.1 netmask 255.255.255.0 # Set interface eth0 to IP address and subnet mask;

- ifconfig eth0:0 192.168.0.1 netmask 255.255.255.0 # Set an additional IP address to the network interface eth0;
iwlist scan # scan the air for the availability of wireless access points;
iwconfig # Utility for configuring wireless network interfaces.
- iwconfig wlan0 # Show the configuration of the wireless network interface wlan0;
-iwconfig wlan0 mode ad-hoc # Specify the network type - ad-hoc;
-iwconfig wlan0 channel 2 # Specify the frequency channel;
- iwconfig wlan0 essid inet # Specify the name of the network. Read more about setting up the distribution of the Internet via wi-fi here: iwconfig ;
route # Setting up routes. Examples:
- route-n # Displays the routing table;
- route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 # add a static route to the network 192.168.0.0/16 through the gateway with the IP address 192.168.1.1 (to remove, change add to del);
netstat # Current network connections. Example:

- netstat -tup # Display active network connections: ;

- netstat -an | grep LISTEN # Shows a list of all open ports;
-netstat -anp -udp -tcp | grep LISTEN # View a list of applications that open ports;
ethtool # Information about the current network connection mode and supported. Examples:

- ethtool eth0 displays eth0 interface statistics with information such as supported and current connection modes;
- ethtool -s eth0 speed 100 duplex full autoneg off # Force network interface speed to 100Mbit and Full duplex mode and disable auto-detection;
tcpdump # Network traffic scanning utility. Example: tcpdump tcp port 80 display all traffic on TCP port 80;
iptables # Firewall configuration utility;
ssh # Connect to a remote computer via ssh. Example: ssh 10.10.10.4 . More: ssh ;
wget # Upload utility. wget -c http://www.example.com/file.iso download the file http://www.example.com/file.iso with the ability to stop and continue later;

whois # Find out information about the domain, example: whois site ;

dig # Checking domain names. Examples in the link: dig ;

Text

Seal

lpstat # View the list of printers. Get a list of all available printers lpstat -a ;
lp # Send to print command. More: ;
lpr # Send to print command. Example: lpr -P Kyocera_Kyocera_FS-4020DN test.txt ;

lprm- # Deleting the print queue;

Users and groups

id # Shows summary information on the current user (login, UID, GID, groups);

adduser # Adding a new user. Example of adding user it: adduser it ;

passwd # Changes the password of the current user;

groupadd # Adding a new group. Example: groupaddITgr ;

usermod # Change user settings. usermod -a -G ITgr it adds the it user to the ITgr group;

userdel # Deleting a user. Example: userdel it ;

groupdel # Deleting a group. Example: groupdelITgr ;

users # Displays a short list of users currently logged into the system;

exit # End the session of the current user;

last # Display user registrations in the system;

Miscellaneous

watch # Every n-seconds, the watch command runs the appropriate command. Example: watch -n 5 "cat /proc/loadavg" Every five seconds, the result of the command to view the average load of the computer will be displayed;

screen # Window manager. More details at the link: screen ;
dc # Calculator;
cal # Calendar. Examples:
-cal-3 # Show previous, current and next month;
- cal 2015 # Calendar 2015;
sleep # Delay for a specified period of time, in the example 10 seconds: sleep 10 ;
history # Shows a numbered list of commands that were executed in this and the previous session;

script # Create a log of your console session. Everything that was entered is saved, and everything that was displayed on the screen. Example: script history.txt . To stop recording, enter exit ;

which # Display the full path of the executable, for example which ifconfig ;

wall # Display a message on all user terminals, example: wall hello ;

reset # Reset terminal settings and clear it;

clear # Clears the terminal screen;

beep # Play a sound signal;

Reference

man # Reference;
man ls # Help on the ls command;

* Some commands require full rights;

** Some commands require additional software to be installed.

  • Sergey Savenkov

    some kind of “scanty” review ... as if in a hurry somewhere