Contacts

Linux console commands. Basic Linux and Unix console commands Ubuntu console commands

A novice user naturally begins to master OS Linux from the graphical interface. But after a while he decides to try working on the command line. Ultimately, almost everyone will be able to do this. This is a rather interesting and exciting process. Only in the command line does the full power of this operating system open. This review lists the most basic commands. All this is in the reference manual - man, but at first you may not be able to use it manually. First try just typing the commands given below without additional parameters(of which there are quite a few and can be found out by asking “command -help” or “man command name”.

Please, if possible, correct or supplement this list in the comments. Many of the commands below are “Unix like”, which means that you can also use them in Unix-based operating systems, for example Mac OS X, etc.

Teams:

  • login request from the user for a name and password (request from the system to the user) to log in to the system (by default, when entering a password, it is not displayed).
  • logout exits the current shell session.
  • startx command to launch the X Window graphical interface (not to be confused with the Windows system. Don't be afraid. This is not it :)).
  • shutdown stops the system and prevents damage file system however, it is used only when working in console mode. When working in X Window mode, do not use.
  • halt quick and correct shutdown of the system.
  • poweroff correct shutdown of the system.
  • reboot correct shutdown with subsequent boot. Reboot.
  • vmstat provides information about processes, memory and CPU load.
  • su login to the administrator session, but you will have to enter a password. To exit this session, type exit and press ENTER.
  • apropos search for a string in the titles and titles of documentation (additionally enter a search word). Gives a list of everything found.
  • cal formatted calendar for the current month (add y and there will be a calendar for the entire current year).
  • date displays the current date and time according to the kernel system clock.
  • oclock a simple clock that hangs on the desktop (many additional options).
  • finger display information about the user whose name is specified in the command.
  • hostname The command displays the identifier of a given network node (its name). root can change the node name to a new one.
  • hwclock your computer's built-in clock. To change the date and time and synchronize with the system clock, root privileges are required.
  • pwd displays the full path to the current directory.
  • tzselect launching a utility that allows you to select the time zone.
  • uname displays information about the used operating system(when you enter additional command parameters, it produces quite a lot of information).
  • uptime shows the current time, session duration, number of users and CPU load.
  • users displays a short list of users working in the system in this moment.
  • w detailed information about all users currently working and also simple login, etc. If you need one user, then specify the name in the parameter.
  • whatis Searches a database of manual pages and displays a short description.
  • who list of users currently working in the system.
  • whereiz finds files, man pages for the specified command.
  • which shows the full path to the command executable.
  • whoami shows the current user ID working in this terminal.
  • write sends a message to another user logged in by copying lines from the sender's terminal to the recipient's terminal.
  • wall sends a message to the terminal of each user currently logged into the system.
  • history shows a numbered list of commands you executed in this and the previous session. If there are quite a lot of them in the history list, you will see the latest ones.
  • jobs displays a list of all running and suspended tasks.
  • kill end the process (you must specify which one).
  • killall will allow you to manage processes using their names or file names, and not identifiers as in kill. All specified processes are terminated.
  • kernelversion shows the major and minor versions of the kernel.
  • nice Allows you to display or configure the priority of a task.
  • ps displays a list of all running processes.
  • pstree shows the hierarchy of system processes, which clearly shows their interdependence.
  • renice sets the priority for the specified task.
  • script allows you to write all output from the terminal to a file. To stop recording, press Ctrl+d. If the file name is not specified, it is written to typescript.
  • times shows the total execution time of processes for the entire system and a given user.
  • top launches a program that allows you to manage processes. And a lot of additional, useful information.
  • CD change the current directory. By default, goes to the current user's home directory (if without parameters).
  • dir Displays files in the current directory in alphabetical order and case sensitive.
  • file shows the content type of the specified file (text, executable, data).
  • find search for files in the current directory. If you specify a path, you can search everywhere.
  • free displays information about random access memory, swap, cache, free memory, shared, etc.
  • ls shows all files in the current directory in alphabetical order. Similar to dir.
  • last shows a list of users who have logged in since the /var/log/wtmp file was created.
  • lastlog checks the login history of registered users. Formats and prints the /var/log/lastlog file.
  • logger sends a request to the syslogd daemon asking it to write a message to the system log.
  • lpr sends the document to the print daemon for printing.
  • chmod changes the file access mode. Character or numeric format.
  • chown change the owner of the specified file. Root access is required.
  • chage used to change the validity period of an account. For administration.
  • chfn changes user information in the /etc/passwd file from which the finger command takes information.
  • chgrp command for an administrator to change the owner group of a file.
  • clear clears the terminal screen (if possible).
  • crontab provides the ability to perform certain tasks on a schedule. It is most often used by the administrator, although users may also have their own tasks.
  • csplit splits the file into several parts. You must specify the splitting method (lines, etc.).
  • cp copies one file to another, or several files to a directory.
  • dd copying a file while simultaneously performing various additional transformations.
  • dc calculator.
  • debugfs used to restore the file system (ext2, ext3) if the fsck command is not enough.
  • df shows the amount of used and free disk space for all mounted file system partitions.
  • du shows the number of disk blocks occupied by each directory file.
  • mc launches the Midnight Commander file manager program in a text console. It resembles MSDOS managers and is quite simple and easy to use. There are a lot of necessary and convenient functions.
  • mkdir creating the specified directory.
  • man reference guide.
  • mcat copies the raw data to a floppy disk.
  • mcopy uses a formatted MSDOS floppy disk to copy files to and from Linux without first connecting the floppy disk to the file system.
  • mdel deletes a file on a formatted MSDOS floppy disk.
  • mdir displays the contents of a directory on an MSDOS floppy disk.
  • mdu shows the disk space occupied by the MSDOS directory.
  • mesg controls access to your terminal so that colleagues cannot bombard you with messages using the write command
  • mformat creates the MSDOS file system on a floppy disk.
  • mkbootdisk used in some distributions to create a boot floppy disk containing everything needed for an emergency boot.
  • mktemp creates a unique file name for temporary work.
  • mlabel creates a volume label on MSDOS on a formatted floppy disk.
  • mmd creates a MSDOS subdirectory on a formatted floppy disk.
  • mmount connects a formatted MSDOS device to the file system.
  • mmove Moves or renames a file on an MSDOS floppy disk.
  • more A tool for page-by-page viewing of a text file.
  • mv renames or moves files or directories.
  • rm deleting the specified file. You can delete a lot.
  • rmdir deleting the specified empty directory.
  • safedelete deleting the specified file to the safedelete directory, where it is stored for some time before being permanently deleted.
  • stat displays all available information about the specified file.
  • touch changes the time the file was last accessed or modified to the current time.
  • undelete Recovers files deleted by the safedelete command.
  • wc shows the number of lines, words and characters in the file.
  • bunzip2 unpacks the specified file 30% faster than gzip.
  • bzip2 compresses the specified file using an accelerated algorithm.
  • bzip2recover makes an attempt to recover data from a damaged bzip2 compressed file.
  • compress compresses the specified file using a different algorithm.
  • uncompress unpacks the file compressed by the previous command.
  • cpio allows you to create archives and extract files from archives. Allows you to copy files. The appropriate parameters must be specified.
  • gpg allows you to encrypt and decrypt a file. Public key encryption method. Allows you to create electronic signatures. If you do not have this program, download http://www.gnupg.org
  • gzip compresses the specified file.
  • gunzip unpacks the specified file (extensions .Z, .gz, .tgz, .zip).
  • gzexe allows you to compress the executable file with specified name so that it is automatically decompressed and executed when the user issues a command to execute the compressed file.
  • gpasswd sets the group password.
  • mcrypt Encrypts the specified file. Created new file in the working directory with the extension .enc. You will be prompted to enter your password. Don't forget it.
  • mdecrypt decrypts the same file. If these utilities are not available, download http://mcrypt/hellug.grl
  • tar places two or more files into a new or existing archive, or extracts them from an archive. When given a directory, archives all files in the directory and subdirectory.
  • talk allows you to conduct an interactive dialogue with an INTERNET user.
  • tee sends output data to two output devices. Can be simultaneously output to the screen and to a file.
  • toe provides information about existing terminals that can be used for further work.
  • touch changes the file creation time to the current one. If the file does not exist, it creates a new, empty file.
  • unarj unpacks or lists the contents of the specified archive in .ARJ format (MS DOS compression format).
  • unzip unpacks and extracts files from archives created by ZIP utilities (Linux, MS DOS, Microsoft Windows).
  • zip archives and compresses files.
  • zipinfo displays information about the contents of the archive. If you specify a name, it will display information about a specific file.
  • zipnote allows you to display and edit comments on files from a ZIP archive.
  • zipsplit allows you to divide the zip archive into small enough parts to write them to removable media, and writes the files to the specified device (floppy disks).
  • zforce adds the .gz extension to all files in the working directory, or to a specified file, that have been compressed but do not have an extension. prevents re-compression.
  • uuencode encodes a binary file for transmission over ASC11 networks.
  • uudecode decodes the above named file.
  • autorun automatically recognizes all available CDROM drives in the system, mounts them when a disc is inserted, and can launch individual applications (such as a player). To use, you need to add parameters to the drive file.
  • badblocks check the specified device for bad sectors (specify device).
  • eject removes media from the specified device. If the device is mounted, the command unmounts it before removing the media.
  • e2fsck checks and, if necessary, restores the damaged file system volume (ext2, ext3).
  • echo Prints a line of text to the standard output device.
  • fdformat formatting a floppy disk. Additionally, enter the device name and the required type of formatting.
  • fg switches a process running in the background to foreground mode.
  • fgconsole shows the number of active virtual consoles.
  • fsck checks and restores the file system.
  • mount mounting the file system.
  • umount unmounting the file system (in both commands you must specify what exactly).
  • rdev when called without parameters, displays information about the current file system.
  • rcp used to copy files from one computer to another.
  • rdate receives the date and time value from another node on the network. Used to synchronize the system time of nodes.
  • rename renames files. Very convenient when there are a lot of files.
  • resize resizes the virtual terminal window in a graphical environment.
  • restore Recovers files archived using the dump command.
  • runlevel displays the current and previous run levels.
  • shred performs secure deletion of a file by first overwriting its contents to another disk.
  • sleep pauses the start of a process for a specified number of seconds.
  • usleep pauses for microseconds.
  • sync Clears file system buffers.
  • cmp produces quick comparison two specified files. If they are identical, then no messages are displayed.
  • column formats the input text from the specified file into a five-column list.
  • diff compares two specified text files. Each difference is displayed in context. Allows you to compare directories.
  • diff3 compares three specified files and displays the results.
  • enscript converts the specified text file in Post Script format. The output can be sent to print or written to a file.
  • fmt This utility formats each line in the specified file so that all lines have the same width.
  • head The utility displays the first ten lines of a file. Several files are also possible.
  • ispell launching an interactive utility to check spelling in the specified file.
  • id Displays the effective user and group ID values ​​for the current user.
  • ifconfig displays the status of the current network configuration or configures the network interface.
  • less displays the contents of the specified file on the screen and allows you to view it conveniently.
  • nl The command numbers the lines in the specified file.
  • paste combines corresponding lines of files into columns. If desired, you can combine several files.
  • pdf2ps converts a PDF file to Post Script. The result is written to disk.
  • pdftotext converts a file from PDF format to text and writes the result to disk.
  • pr prepares text for printing by formatting it into pages. You can prepare multiple files.
  • sort The command allows you to sort the lines of a file in alphabetical order.
  • split splits the file into parts.
  • zcat;zmore displays the contents of a gzip compressed file on the screen without decompressing it.
  • zcmp
  • zdiff compares gzip compressed two files without decompressing.
  • zegrep;zfgrep;zgrep search for a specified string or expression in a gzip compressed file, without unpacking.
  • aumix interactively launches a utility that controls various sound card settings.
  • cdda2wav The utility is designed to record audio tracks from an audio CD into WAV files. If the file name is not specified, then the recording goes to the audio.wav file in the current directory.
  • cdlabelgen The command is designed to prepare covers for CD boxes. The result is in a Post Script file format. A Perl language interpreter of at least version 5.003 is required.
  • cdp launch the audio CD player in text mode.
  • cdparanoia reads audio tracks from audio compacts and writes to WAV, AIFF, RAW files.
  • combine combines two or more graphic files into one. A huge number of special effects. It is part of the Image Magick package and can be taken from http://www.imagemagick.org
  • convert converts the specified input graphic file into an output one. Recognizes many formats. Download in the same way as the previous one.
  • identify determines the format and characteristics of a graphic file and checks for integrity and errors.
  • mogrify converts a graphic file and overwrites the original one.
  • montage converting multiple files into a combined image. Download http://www.imagemagick.org
  • mpg123 plays an MP3 audio file on the main playback device. Enter the file name or its Internet address. To stop playback Ctrl+c. To stop and exit the program, press Ctrl+c twice.
  • play Plays a sound file with the specified name. Automatically recognizes the file type. Allows you to add various sound effects to played files.
  • playmidi plays sound files in MIDI format.
  • rec Records input from microphone or other inputs into an audio file. The file type should be specified using the (type) parameter. It is possible to add sound effects.
  • sox converts samples from the input signal format to the output with the addition of effects.
  • emacs launching the Emacs text editor.
  • joe An easy-to-use editor that works in text mode.
  • pico simple and easy to use text editor.Convenient for editing configuration and simple files.
  • vi launching the classic text editor VI for UNIX systems.
  • dmesg displays kernel messages on the screen, including those displayed at startup and afterwards. To make it easier to read, enter dmesg|less.
  • groupadd creating a user group with the specified name.
  • groupdel deletes the group with the specified name.
  • groupmod changes the settings of the group with the specified name.
  • mkpasswd creates a high-quality password that is nine characters by default and contains at least mixed-case letters and numbers.
  • passwd allows the user with the specified name to change their password account. root can change any user's password.
  • pwgen creates a high-quality password that is easy to remember. The password length is indicated by a number. If this utility is not available, download http://metalab.unc.edu/pub/Linux/system/security
  • quota shows current statistics Disk usage and current limits for the user or group with the specified name.
  • quotacheck examines the file system for disk space usage.
  • quotaon Enables or disables disk space usage restrictions.
  • rpm launches the package manager, a utility that allows you to install, check and update packages with the rpm extension.
  • rpmfind search for the required package in the RPM package database via the INTERNET. Latest version of the utility http://www.rpm.org
  • tmpwatch deletes all files in the specified directory if they have not been accessed within the last n hours. Clears temporary directories.
  • useradd creating a new user with the specified name.
  • userdel deletes the user with the specified name.
  • usermod changes the settings of the user with the specified name.
  • fetchmail mail receiving utility. Works in the background. Downloads mail from the specified server. If it is not there, you can download it from http://www.freshmeat.net
  • ftp establishes a connection to the specified node and allows you to download or upload files.
  • lynx launching a console WEB browser.
  • mail utility for editing and viewing e-mail. Sending and receiving letters.
  • netstat Displays information about the network subsystem. There are a lot of settings and parameters.
  • ping sending to specified address packets to check the possibility of connecting to this node.
  • telnet opens a terminal window on the remote host and starts an interactive session.
  • wvdial the program connects to the INTERNET via the PPP protocol using the parameters stored in the /etc/wvdial.conf file
  • wvdialconf searches for a modem, determines the port to which it is connected, its initialization string and the maximum data transfer rate. This information is automatically written to a file (see above). Root access is required.
  • ar archiving tool designed to create and unpack an archive.
  • arch displays information about the CPU architecture.
  • at Queues jobs for later execution at a specified time.
  • atq shows a list of tasks that are queued for execution.
  1. && . Strictly speaking, this is not a team. If you want to execute several commands at once, put a double ampersand between them like this: first_command && second_command. The terminal will execute the commands in order. You can enter as many commands as you like.
  2. alias Assigns names you create to long commands that you can't remember. Enter the alias long_command short_command.
  3. cd. Changes the current terminal folder. When you start the terminal, it uses your home folder. Enter cd folder_address, and the terminal will work with the files that are located there.
  4. clear. Clears the terminal window of all messages.
  5. history. Displays all the commands you have recently entered. Additionally, you can switch between recent commands using the Up and Down keys. If you do not want the command you entered to be written down, put a space in front of it like this: your_command.
  6. man. Displays a guide to programs and commands. Type man package_name or man your_command.
  7. whatis. Displays short description any program. Enter the command and the program name whatis package_name.

To perform many actions on the system, such as installing and uninstalling programs, you will need administrator rights, or super root user, as it is called in Linux.

  1. sudo This command will give you superuser rights. Type sudo before the command you want (for example, sudo apt upgrade) to run it as an administrator. The system will ask you for your password.
  2. sudo su . After this command, all commands you enter will be executed as the superuser until you close the terminal. Use it if you need to run a lot of commands with administrator rights.
  3. sudo gksudo . Command to run a GUI application with administrator rights. For example, if you want to move or change system files, enter sudo gksudo nautilus (specify the one file manager which you are using).
  4. sudo!! . This command will run the previously entered command with administrator rights. Useful if you typed the command without sudo .

Do not execute commands as superuser that you do not understand.

Installing and uninstalling applications in Linux is performed by package managers. In Ubuntu the package manager is called apt, in Fedora - dnf, in Arch and Manjaro - pacman. They download applications from online repositories, package sources. Commands should be given to them with superuser rights.

apt (Debian/Ubuntu/Mint)

  1. sudo apt install package_name. Install the required package.
  2. sudo apt-add-repository repository_address. Add a third-party repository.
  3. sudo apt update . Update package information.
  4. sudo apt upgrade . Update all packages to the latest (perform after apt update).
  5. sudo apt remove package_name. Remove unnecessary package.
  6. sudo apt purge package_name. Remove an unnecessary package with all dependencies if you want to free up more space.
  7. sudo apt autoremove . Remove all unnecessary dependencies, orphan packages and other garbage.

dnf (Red Hat/Fedora/CentOS)

  1. sudo dnf install package_name. Install the required package.
  2. sudo dnf config-manager --add-repo repository_address. Add a third-party repository.
  3. sudo dnf upgrade . Update all packages to the latest ones.
  4. sudo dnf remove package_name. Remove unnecessary package.
  5. sudo dnf autoremove . Remove all unnecessary dependencies.

pacman (Arch/Manjaro)

  1. sudo pacman -S package_name. Install the required package.
  2. sudo yaourt -S package_name. Install a package from AUR if it is not in the main repository.
  3. sudo pacman -Sy . Update package information.
  4. sudo pacman -Syu . Update all packages to the latest ones.
  5. sudo pacman -R package_name. Remove unnecessary package.
  6. sudo pacman -Rs package_name. Remove an unnecessary package with all dependencies.

You can install and remove several packages at once by simply listing them separated by a space.

sudo apt install firefox clementine vlc

If you want to install a package but don't know its exact name, type the first few letters of the package name and press Tab twice. The package manager will show all packages whose names start with the same name.

  1. kill. This command is for forced termination processes. You need to enter kill PID_process. The PID of a process can be found by typing top .
  2. xkill. Another command to end processes. Enter it, then click on the window you want to close.
  3. killall. Kills processes with a specific name. For example, killall firefox.
  4. top. Displays a list of running processes, sorted depending on CPU resource consumption. A kind of terminal “System Monitor”.

Viewing and editing files

  1. cat. When the command is used with a single text file (like this: cat file_path), it displays its contents in a terminal window. If you specify two and more files, cat path_to_file_1 path_to_file_2 , it will glue them together. If you enter cat file_path_1 > new_file, it will merge the contents of the specified files into a new file.
  2. chmod. Allows you to change file permissions. Can be useful if you want to make changes to a system file.
  3. chown. Changes the owner of a file. Must be executed with superuser rights.
  4. file. Displays information about the specified file.
  5. nano . Opens a simple text editor. You can create a new text file or open an existing one: nano file_path.
  6. rename. Renames a file or several files. The command can also be used for files by mask.
  7. touch. Changes the date the specified file was last opened or modified.
  8. wget. Downloads files from the Internet into a terminal folder.
  9. zip. Unpacks and compresses archives.

Creating and deleting files and folders

  1. mkdir. Creates new folder in the current terminal folder or in the specified folder: mkdir folder_path.
  2. rmdir. Deletes the specified folder.
  3. rm. Deletes files. Can delete as separate file, and a group corresponding to certain characteristics.

Copying and moving files

  1. cp. Creates a copy of the specified file in the terminal folder: cp path_to_file. Or you can specify the destination cp path_to_file path_to_copy.
  2. mv. Moves a file from one folder to another. You can specify a name for the file to be moved. Funnily enough, in Linux this command can also be used to rename files. Just specify the same folder where the file is located and a different name.

Search files

  1. find . Search files by specific criteria, such as name, type, size, owner, creation and modification date.
  2. grep. Search for text files containing specific strings. The criteria are very flexible.
  3. locate. Searches for files and folders whose names match the query and displays their paths in the file system.

  1. lsblk. This command shows you what drives you have on your system and what partitions they are divided into. The command also displays the names of your partitions and drives, in the format sda1, sda2 and so on.
  2. mount Mounts drives, devices, or file systems so you can work with them. Typically, devices will connect automatically as soon as you click on them in the file manager. But sometimes you may need to mount something manually. You can connect anything: disks, external drives, partitions and even ISO images. This command must be executed with superuser rights. To mount an existing disk or partition, enter mount sdX .
  3. umount. Dismounts file systems. The umount sdX command will mount the external media's file system so you can eject it.
  4. dd. This command copies and converts files and partitions. It has many different uses. For example, dd if=/dev/sda of=/dev/sdb will do exact copy sda partition on sdb partition. dd if=/dev/zero of=/dev/sdX will erase the contents of the specified media with zeros so that the information cannot be recovered. And dd if=~/Downloads/ubuntu.iso of=/dev/sdX bs=4M will make bootable media from the distribution image you downloaded.

Linux Commands for User Management

  1. useradd. Registers a new user. Enter useradd username and the user will be created.
  2. userdel. Deletes the user's account and files.
  3. usermod. Changes a user account. May move the user's home folder or set a date for the account to be locked.
  4. passwd. Changes account passwords. Regular user can change the password of only his own account, a superuser can change the password of any account.

Linux Commands for Network Management

  1. ip. Multifunctional team to work with the network. The ip address show command displays information about network addresses, ip route controls routing and so on. By issuing the commands ip link set ethX up, ip link set ethX down, you can turn connections on and off. The ip command has many uses, so it's best to read the manual before using it, or type ip --help
  2. ping. Shows whether you are connected to the network and helps determine the quality of the connection.

And one more thing

Finally, the main Linux commands. They put a cow on the screen that can talk to you (don't ask what the developers use).

  1. cowsay anything. The cow will say what you tell it.
  2. fortune | cowsay. The cow will give out a smart (or not so smart) thought or quote.
  3. cowsay -l . Lists all animals that can be displayed in the terminal. In case you don't like cows.
  4. fortune | cowsay -f animal_from_list. The animal of your choice begins to spout quotes, sometimes relevant ones.
  5. sudo apt-get install fortunes fortune-mod fortunes-min fortunes-ru . Will force the entire zoo to speak Russian. Without this, animals quote Twain and Wilde.

These are not all Linux commands. If you need to know in detail the parameters and how to use Linux commands, you can use the built-in tutorial. Type man your_command or your_command --help .

When starting to study the Linux console, you cannot do without knowledge console commands.

This note lists the main Linux console commands, available both when working at 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 logging off your current session.

The invitation sign for users is $, and for the root superuser it is #.

Usually the team 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 that sudo uses 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. For automatic check and error correction, you need to run the command with the ‘-y’ switch: fsck -y

uptime command

uptime shows the 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 the 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, busy and free space and mount points. Convenient to use with the -h switch (the size is displayed in Gb):

du command

du— show the size of an individual file:

ifconfig command

ifconfig- show network settings(interfaces):

ping command

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

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 server...):

ps command

ps– display your currently active processes

top command

top– show all running processes

kill command

kill pid – kill the process with id pid

killall command

killall ispmgr – kill all processes named ispmgr

man command

man passwd — display help about the passwd command

passwd command

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

ls command

ls– list of files and directories (with the switch “-la” - 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- remove a directory from the file system. Removing a directory and its contents can also be done with the rm -rf command (the -r switch for directories).

rm command

rm file - delete file file with confirmation

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

Team mv

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

1 - renaming the directory folder to folder00:

2 - moving the file to the directory:

cat command

cat> file – direct standard input to file (that is, create a file with the necessary content):

To complete entering information into this file, you must press the keyboard shortcut as usual .

cat file — show the contents of the file file:

cat file file1 > file22 — create file file22 and write data from files file and file1 to it:

Less, more command

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

chmod command

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

4 – reading (r)
2 – record (w)
1 – version (x):

Team chown

chown- change the owner of the file

tar command

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

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

wget command

wget— copy a 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- reboot the server

halt command

halt- shut down the server

shutdown command

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

Linux console commands, or as they also say the command line, are a kind of intermediate link between the user and the computer itself. In order for the machine to carry out 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, it appeared additional tool a mouse that greatly simplified the entire process of information exchange and made it more accessible to all users. However, the console today remains powerful and sometimes very convenient tool to perform 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?

//basic formula

sudo apt-get command

//as an example, update all packages

sudo apt-get upgrade

Basic apt-get commands when working with packages.

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

Options:

-h, --help //reference
-q, --quiet //hide the progress indicator
-qq //do not show anything except errors
-d, --download-only //just receive packets and exit
-s, --simulate //perform event simulation
-y, --yes //automatic 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 //assemble the package after receiving
-D //when deleting, remove dependent components
-V //show package version numbers in detail
--no-remove //if the packages are marked to deleted., then apt-get off
--force-yes //force execution of the specified operation

Funny.

apt-get moo

You should see a cow asking, “Did you moo today?”

"aptitude" utility.

Let's consider another very good utility entitled " aptitude", in fact, this is the same as " apt-get", but 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, let's install the utility itself:

sudo apt-get aptitude

Now if you type: aptitude, 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 times you install them, aptitude will automatically resolve all dependencies, all you have to do is agree (y) and press (enter). Also, by analogy, you can remove packages:

sudo aptitude remove package_name1
or
sudo aptitude purge package_name1

The first command deletes only the package files without touching the settings, the second deletes everything completely. You can view the package description like this:

aptitude show package_name

In general, this utility is an absolute analogue of " apt-get", but when installing and removing packages, it is advisable to use it rather than " apt-get". At least on the official website Ubuntu give exactly the same recommendations.

Other console commands.

List of commands related to information.

hostname //machine network name
whoami //current user name
uname -m //shows the machine architecture
uname -r //kernel version
sudo dmidecode -q //inform. about the device. ensuring the system
cat /proc/cpuinfo //information about the processor
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 entire year 201

Commands related to reboot and shutdown processes.

shutdown -h now //turn off the system
init 0 //turn off the system
telinit 0 //turn off 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 //go to home directory
CD.. //go to higher level
cd ../.. //go up 2 levels
cd- //go to 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 in the specified location
rm -f file1 //delete file with name file1
rmdir dir1 //delete directory with name dir1
rm -rf dir1 //delete directory dir1 and all its contents
rm -rf dir1 dir2 //delete directories dir1\dir2 and contents
mv dir1 new_dir //rename / move directory
cp //copy files/folders
ln -s //create a symbolic link
chmod //assigning rights to files

Search files and directories.

Forgot where you saved it? No problem! You can find everything in the console.

find / -name file1 //search for files, director. beginning With /
find / -user user1 //search for files, direct. Withuser1
find /home/user1 -name \*.bin //search for files .bin V / home/ user1
find /usr/bin -type f -atime +100 //claim bin. files, sudden 100 days
find /usr/bin -type f -mtime -10 //claim files created/edited 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 programhalt

At first glance, all this may look somewhat intimidating, but this is only at first glance. Don’t immediately rush into panic and immediately return to Windows(y). Modern distributions, as well Ubuntu in particular, it completely allows you to do without command line. However, the command line, in some cases, is much more convenient than the graphical interface. Also, it is not at all 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 that you can use if necessary.

Of course, this is not 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, you can find and download a lot of things there, the only question is whether it is necessary it's all for you. I generally doubt that today there is at least one person in the whole world who would know by heart all the existing console commands (maybe I’m wrong).

Linux command references: http://books.tr200.ru/v.php?id=278389

Modern PC users are accustomed to a graphical interface. However, sometimes you have to use the command line interface, that is, enter certain commands manually. For example, in the absence graphical shell, when restoring and configuring the system, etc. Moreover, using the command line, performing some actions is faster and more convenient than using the usual graphical interface.

Command line is a very powerful system management tool. Some novice users are afraid to work in the console, believing that it is too complicated and unclear. In fact, this is not so; it is enough to master some operating techniques and a few simple commands, and it will be much easier to understand the remaining commands. The graphical interface became widespread not so long ago - at the end of the last century. Before that, all computer users worked with the command line.

In any case, Linux users should master working in the console; these skills will definitely be useful to them in the future. In this article we will look at working with the console and terminal, as well as the main frequently used Linux commands, without claiming to be complete, since their full description with examples may take more than one volume.

To access the console while in graphical mode, you need to press a key combination Ctrl+Alt+F1. Next, you will need to enter your username and password, as when booting the system. You can open multiple consoles using keyboard shortcuts Ctrl+Alt+F2, Ctrl+Alt+F3 etc. (up to F6) and run in them various programs simultaneously. To return to the graphical environment, click Alt+F7, while the consoles remain open and the programs running in them will continue to work.

Rice. 1. Konsole terminal emulator

Commands in Linux consist of several parts: the command itself, keys (options) and parameters, which can be mandatory or optional. For example, in a team ls -la /var/www(hereinafter we will highlight the commands in bold): ls is a command, la are keys, which are most often separated by a minus sign “-”, and the parameter in this case is the /var/www directory. Keys can be short and long: short ones consist of one letter and are separated by one minus “-”, long keys are separated by two minuses “--”. Short keys can be combined into one, for example commands ls -l -a -t -r And ls -latr identical. The most popular long switches are --help and --version. By typing the --help key after any command (for example ls --help), we will get brief help about it. The --version switch is used to display the program version.

Please note that commands, switches, file names in Linux are case sensitive. That is, L.S. And ls- This different teams, if instead ls dial L.S., then the effect will be unexpected. It is convenient to type long commands using the “Tab” key, which serves for auto-completion; just type the first letters of the command name and press this key. If there are several commands that begin with the characters entered, then they will be displayed on the screen, in this case you need to type one or more characters and press “Tab” again. Similarly, the Tab key can be used to speed dial parameters, long file names, etc. Using the cursor keys, you can view and edit already entered commands.

You can also use the following keyboard shortcuts:

Ctrl+C- interrupt the program (note that in the graphical environment the same key combination is used for copying).

Ctrl+Shift+C- copy the selected information to the clipboard; you can use the mouse to select it.

Ctrl+Shift+V- insert information from the buffer. To insert text, it is also convenient to use the middle mouse button (scroll wheel), having previously selected the text.

Ctrl+S- suspend output to the terminal.

Ctrl+Q- resume output to the terminal. Although usually you can use any key for this. Sometimes it helps if the terminal is frozen.

Ctrl+Z- stop the program. To continue you need to type the command fg(or bg to continue the program running in the background).

Ctrl+D- exit the terminal, close the console, break the connection with the remote computer.

Now let's move on to looking at Linux commands.

Information commands

man command - outputs detailed information about the Linux command, keys, etc. For example: man date.

Unfortunately, not all manuals are translated into Russian; basic knowledge of English may be required.

date- displays the current date and time.

uname -a- displays information about the system.

who- displays a list of users who are currently logged into the system. Don't be alarmed if several users are found on personal computer, this does not mean that it was hacked by hackers. Pay attention to their names. Every open terminal, including graphic, the system considers as a separate user.

w- similar who shows users in the system, but, in addition, displays Additional information- what commands users execute, and how loaded the processor is.

free- displaying information about RAM.

top- displays information about processes, processor load, and memory allocation.

df -h- displays information about hard drives.

uptime- displays system operating time, number of users, processor load.

pwd- shows the current directory.

time- measures the running time of a program, for example time ls.

echo- prints a line of text to the standard output device. echo Hello- will display the word “Hello”, echo *- displays a list of files in the current directory. echo $- will print the sum of numbers 2 and 3.

Commands for working with files

ls- displays a list of files in the current directory. To display a list of files in any directory, you need to type the directory path after the command, for example: ls /usr/bin. Some ls command options:

A - show hidden files;

S - specify the file size in blocks;

T - sorting by file modification time, new files first;

X - sorting by file name extension, files without extension are displayed first;

L - extended output format: shows attributes, owners and group of files, size, date and time of their creation;

R - reverse the sort order. For example, the command

ls -lat /etc will display the contents of the /etc directory in expanded form and sorted by the time the files were created.

cp- copying files. cp doc1 doc2- will create a copy of file doc1 under the name doc2.

rm- deleting files. rm doc- will delete doc file. rm *- will delete all files in the current directory. rm *doc- will delete all files that end in doc. The -i switch is used to confirm the deletion of each file, the -r switch is used to delete directories and files within these directories.

rmdir- deleting a directory. rmdir alex- will delete the alex directory.

You need to be very careful with commands rm And rmdir, especially in superuser mode, since you can delete not only your own files, but also system files, which can lead to system crash.

pwd- output of the current directory.

mkdir- creating a new directory. mkdir alex- will create the alex directory.

mv- moving or renaming files. mv new old - renames the file new to old.

cat- connecting files or outputting files to standard output device. cat doc- will output the doc file.

cat /proc/cpuinfo- will display detailed information about the processor, cat /proc/version- about the Linux kernel version.

touch- creating an empty file.

touch doc- will create a doc file. find- search for files. find / -name "doc*"- will find all files that start with doc.

tar- a program for working with archives. tar -zxvf file.tar.gz- unpacks the archive file.tar.gz. tar -cvf my.tar myfile- will archive the file myfile, creating a my.tar archive.

more- output files with a stop for viewing, in contrast to cat, which outputs the entire file at once. You can scroll through text line by line, using the enter key, or page by page using the space bar.

less- similar file viewer more, but allows you to scroll the text up and control using the cursor keys.

nano- a simple full-screen text editor. Recommended for beginners, as it contains a minimum of functions and basic commands are displayed on the screen.

vi is a fairly powerful text editor, but it has its own non-standard command system, so it takes time to master.

mc(Midnight Commander) is a powerful file manager, similar to Norton Commander for DOS or FAR for Windows. Allows you to delete, copy, rename, view, edit files, change their attributes, etc. Midnight Commander is usually not included in the standard set of system programs, so it must be installed separately. But it is highly recommended for use, as it greatly simplifies working with files.

Installation and removal of programms

Various utilities are used to install and uninstall programs, depending on the version of the Linux distribution. On Debian-based distributions (Ubuntu, Linux Mint etc.) commands are used for this purpose apt-get or aptitude. The first option is simplified, the second has greater functionality. Some actions, such as installation and removal, must be performed as root, or use the command sudo.

sudo apt-get update- receiving a new list of packages.

sudo apt-get upgrade- update programs, before this you need to update the list of packages by running the previous command. It is advisable to run both commands periodically (often this is done automatically), as well as before installing new programs.

sudo apt-get install mc- installation of the mc program.

sudo apt-get remove mc- uninstalling the mc program. Red Hat-based distributions that use RPM packages often use a manager yum.

yum update- system update.

yum install mc- installation of the mc program.

yum remove mc- deleting the mc program. There are other package managers and software installation options.

Network commands and working with remote computers

ping- checking communication with a specific address on the network. ping google.com- checking the availability of the site google.com, you can also use the IP address: ping 192.168.1.5. If there is no answer, this does not mean 100% that there is no connection; sometimes the work of this command is blocked on the network.

traceroute- shows the route of traffic. For example: traceroute google.com. Allows you to determine in which part of the network problems occur.

telnet- connection to a remote computer. Allows you to execute commands on another computer. Mainly used in internal network, since the traffic is not encrypted. Example: telnet 192.168.1.1.

ssh- connection to a remote computer via an encrypted channel. ssh- connection to the server site.com user alex. To connect via a non-standard port, use the -p switch, for example

ssh -p 12345- connection to server 111.222.123.123 for root user via port 12345.

ftp- connection to a remote computer via file transfer protocol. ftpsite.com- connection to the site.com server.

sftp- the command is similar to ftp, but the connection occurs via an encrypted protocol.

route -n- shows the routing table.

ifconfig- Information about network connections and their settings.

hostname- displays or changes the computer's network name.

whois site or IP address - displays information about the domain, the owner of the domain name or IP address, for example whois google.com or whois 8.8.8.8.

dig- displays DNS information, for example diggoogle.com. You can access any DNS server by specifying it as follows: dig @8.8.8.8 google.com. To obtain information from the DNS server, you can also use programs host And nslookup, specifying a domain name or IP address after them, but these utilities have reduced functionality compared to dig.

wget- a program for downloading files, pages, sites from the Internet. wget http://site.com- download home page site.com. wget -r -l 10 -k http://site.com- will load the site completely.

lynx, links, links2(3 separate commands) - text browsers, allow you to browse websites directly from the console.

Administration commands

su- change of user. su alex- will change the user to alex. Typing su without parameters, you will get superuser rights (root), with the hint symbol $ will change to # .

You should not be in this mode all the time, but it is better not to use it at all, but use the command sudo.

To exit the session and return to the previous user, you need to dial exit.

sudo- allows you to execute other programs with superuser rights, typed before another command, for example

sudo rm file- will delete a file created by any user.

sudo -i or sudo -s- analogues of the command su.

Use command sudo you also need to be very careful and only if necessary.

passwd- change the password of the current user. passwd alex- change the alex user password.

adduser or useradd- add a new user. adduser Katya- will add user katya. After typing the command, you need to enter a password. To execute the command you must be a superuser.

userdel- delete a user. userdel vasya- will delete the user vasya.

groupadd- Creation new group. groupadd students- will create a group students.

groupdel- deleting a group. groupdel students- will delete the students group.

chmod- change the access rights of a file or directory. chmod 644 file- will set permissions to 644 on the file. chmod +x file- will give the file execution rights.

chown- change the owner of the file. chown alex file- as a result of executing this command, alex will become the owner of the file.

chgrp- change the file group. chgrp students laba1- change the group of the laba1 file to students.

Commands for working with processes

ps- display a list of processes. p.s. axu- see all processes. p.s. | grep win- display all processes where “win” characters occur.

kill- kill the program, after the command the program number (process identifier - PID) is indicated, which can be found using the ps command. Example: kill 1234.

killall command- terminates all processes started using the specified command.

bg- continue the program running in the background, for example after a key combination Ctrl+Z. The PID can be specified after the command:

bg 1234.fg- continue program execution as usual, PID can also be specified.

Other Linux commands and programming languages

Some commands from this list may not be available in standard distributions; they can be installed separately.

sed- a powerful text processing utility.

awk- a language for text processing.

grep- text search utility using regular expressions, often used in conjunction with other commands. grep "^a" "text.txt"- will show all lines in the text.txt file that begin with the letter a.

emacs- an advanced text editor with big amount functions, even built-in games. For advanced users.

gcc- a C language compiler, with which you can obtain executable program files that are distributed in source code. Or compile your programs.

gcc hello.c -o privet- compilation of the hello.c program, the result of compilation will be a program called privet. By default (without the -o option), the output file will be named a.out. GCC is a whole set of compilers (GNU Compiler Collection). In addition to C, there is support for programs in C++, Fortran, Ada, Objective-C, Java and Go.

g++- C++ language compiler from GCC. perl is a powerful scripting language.

python- calling the Python language interpreter. It is a modern and powerful language that can be recommended for beginners.

exit- ending the current session, can be used to disconnect from remote computer, closing the terminal.

shutdown -h now- command to shut down the system, turn off the computer. An analogue is the command halt. If you use the -r switch instead of the -h switch, the system will reboot. You can specify the time after which the command will be executed. Now means now.

shutdown -r +10- reboot the computer after 10 minutes. The -c switch cancels the execution of the command. To execute the command you must have root rights.

reboot- reboot the computer, analogue shutdown -r.

Did you like the article? Share it