Table of contents:

71 Linux commands for all occasions. Almost
71 Linux commands for all occasions. Almost
Anonim

You can do almost anything in the Linux terminal: configure the system, install and uninstall applications, manage disks and files, and even talk to cows.

71 Linux commands for all occasions. Almost
71 Linux commands for all occasions. Almost

Linux commands for navigating the terminal

Linux commands for navigating the terminal
Linux commands for navigating the terminal
  1. &&

    … Strictly speaking, this is not a command. If you want to execute several commands at once, put a double ampersand between them like this:

    first_command && second_command

  2. … The terminal will execute the commands in order. You can enter as many commands as you like.
  3. alias

    … Assigns the names you create to long commands that you cannot remember. Enter

    alias command-long short-command

  4. .
  5. cd

    … Changes the current terminal folder. When you start the terminal, it uses your home folder. Enter

    cd folder_address

  6. , and the terminal will work with the files that are there.
  7. clear

  8. … Clears all messages from the terminal window.
  9. history

    … Displays all the commands you have recently entered. In addition, you can switch between recent commands using the Up and Down keys. If you don't want the command you entered to be written down, put a space before it like this:

    your team

  10. .
  11. man

    … Displays a guide to Linux programs and commands. Enter

    man package_name

    or

    man your_command

  12. .
  13. whatis

    … Displays a short description of a program. Enter the command and the name of the program

    whatis package_name

  14. .

Linux commands for obtaining superuser rights

Linux commands for obtaining superuser rights
Linux commands for obtaining superuser rights

To perform many actions on the system, for example, to add and remove programs, you need administrator rights, or the superuser root, as it is called in Linux.

  1. sudo

    … This command will give you superuser rights. Enter

    sudo

    before the command you want (e.g.

    sudo apt upgrade

  2. ) to run it as an administrator. The system will ask you for a password.
  3. sudo su

  4. … After this command, all the commands you enter will be executed on behalf of the superuser until you close the terminal. Use it if you need to execute a lot of commands with administrator rights.
  5. sudo gksudo

    … Command to run a GUI application as an administrator. For example, if you want to move or modify system files, enter

    sudo gksudo nautilus

  6. (specify the file manager you are using).
  7. sudo !!

    … This command will run the previously entered command with administrator privileges. Useful if you typed a command without

    sudo

  8. .

Do not execute commands on behalf of the superuser that you do not understand.

Linux commands for managing the package manager

Linux commands for managing the package manager
Linux commands for managing the package manager

Installing and uninstalling applications on Linux is done by package managers. Ubuntu and Debian call the package manager apt, Fedora calls dnf, Arch and Manjaro call 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

  2. … Install the required package.
  3. sudo apt-add-repository repository_address

  4. … Add a third party repository.
  5. sudo apt update

  6. … Update package information.
  7. sudo apt upgrade

    … Update all packages to the most recent (run after

    apt update

  8. ).
  9. sudo apt remove package_name

  10. … Remove unnecessary package.
  11. sudo apt purge package_name

  12. … Remove an unnecessary package with all dependencies if you want to free up more space.
  13. sudo apt autoremove

  14. … Remove all unnecessary dependencies, orphaned packages and other junk.

dnf (Red Hat / Fedora / CentOS)

  1. sudo dnf install package_name

  2. … Install the required package.
  3. sudo dnf config-manager --add-repo repository_address

  4. … Add a third party repository.
  5. sudo dnf upgrade

  6. … Update all packages to the most recent.
  7. sudo dnf remove package_name

  8. … Remove unnecessary package.
  9. sudo dnf autoremove

  10. … Remove all unnecessary dependencies.

pacman (Arch / Manjaro)

  1. sudo pacman -S package_name

  2. … Install the required package.
  3. sudo yaourt -S package_name

  4. … Install a package from the AUR if it is not in the main repository.
  5. sudo pacman -Sy

  6. … Update package information.
  7. sudo pacman -Syu

  8. … Update all packages to the freshest.
  9. sudo pacman -R package_name

  10. … Remove unnecessary package.
  11. sudo pacman -Rs package_name

  12. … Remove unnecessary package with all dependencies.

You can install and uninstall multiple 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 do not know its exact name, enter the first few letters of the package name and press Tab twice. The package manager will show all packages that start with the same name.

Linux commands for managing processes

Linux commands for managing processes
Linux commands for managing processes
  1. kill

    … This command is used to force the termination of processes. You need to enter

    kill process_PID

    … The PID of the process can be found by entering

    top

  2. .
  3. xkill

  4. … Another command to terminate processes. Enter it, then click on the window you want to close.
  5. killall

    … Kills processes with a specific name. For example,

    killall firefox

  6. .
  7. top

  8. … Displays a list of running processes, sorted based on CPU consumption. A kind of terminal "System Monitor".

Linux commands for managing files

Linux commands for managing files
Linux commands for managing files

Viewing and modifying files

  1. cat

    … When the command is used with one text file (like this:

    cat path_to_file

    ), it displays its contents in a terminal window. If you specify two or more files,

    cat path_to_file_1 path_to_file_2

    she will glue them together. If we introduce

    cat path_to_file_1> new_file

  2. , it will merge the contents of the specified files into a new file.
  3. chmod

  4. … Allows you to change the file permissions. This can be useful if you want to make changes to the system file.
  5. chown

  6. … Changes the owner of the file. Should be run with superuser rights.
  7. file

  8. … Displays information about the specified file.
  9. nano

    … Opens a simple text editor. You can create a new text file or open an existing one:

    nano path_to_file

  10. .
  11. rename

  12. … Renames a file or multiple files. The command can also be used for mass renaming of files by mask.
  13. touch

  14. … Changes the date when the specified file was last opened or modified.
  15. wget

  16. … Downloads files from the internet to a terminal folder.
  17. zip

  18. … Unpacks and compresses archives.

Creating and deleting files and folders

  1. mkdir

    … Creates a new folder in the current terminal folder or in the specified folder:

    mkdir folder_path

  2. .
  3. rmdir

  4. … Deletes the specified folder.
  5. rm

  6. … Deletes files. It can delete both a 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. .
  3. mv

  4. … Moves a file from one folder to another. You can specify a name for the relocatable file. Funnily enough, on Linux, this command can be used to rename files as well. Just specify the same folder where the file is located and a different name.

Search for files

  1. find

  2. … Search for files by specific criteria such as name, type, size, owner, creation and modification date.
  3. grep

  4. … Search for text files containing specific strings. The criteria are very flexible.
  5. locate

  6. … Search for files and folders whose names match the query and display their paths in the file system.

Linux commands for working with partitions

Linux commands for working with partitions
Linux commands for working with partitions
  1. lsblk

  2. … This command demonstrates what disks are 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.
  3. mount

    … Mounts Linux drives, devices or file systems for you to work with. Usually devices are connected automatically as soon as you click on them in the file manager. But sometimes you may need to mount something manually. You can mount anything: disks, external drives, partitions, and even ISO images. This command must be executed with superuser rights. To mount an existing disk or partition, type

    mount sdX

  4. .
  5. umount

    … Dumps filesystems. Command

    umount sdX

  6. will unmount the file system of the external media so you can eject it.
  7. dd

    … This command copies and converts files and sections. It has many different uses. For example,

    dd if = / dev / sda of = / dev / sdb

    will make an exact copy of the sda partition on the sdb partition.

    dd if = / dev / zero of = / dev / sdX

    will overwrite the contents of the specified media with zeros so that the information cannot be restored. A

    dd if = ~ / Downloads / ubuntu.iso of = / dev / sdX bs = 4M

  8. will make bootable media from the distribution image you downloaded.

Linux commands for system management

Linux commands for system management
Linux commands for system management
  1. df

  2. … Displays the size of your disk and how much free space is left on it.
  3. free

  4. … Displays the amount of available and used RAM.
  5. uname

    … Displays system information. If you enter

    uname

    the terminal will only report Linux. But the team

    uname -a

  6. displays information about the computer name and kernel version.
  7. uptime

  8. … Tells how long your system has been running.
  9. whereis

  10. … Displays the location of the executable file for the desired program.
  11. whoami

  12. … Calls the username.

Linux commands for user management

Image
Image
  1. useradd

    … Registers a new user. Enter

    useradd username

  2. and the user will be created.
  3. userdel

  4. … Removes user account and files.
  5. usermod

  6. … Changes the user account. Can move the user's home folder or set a date when the account will be locked.
  7. passwd

  8. … Changes account passwords. A regular user can change the password of only his own account, the superuser can change the password of any account.

Linux commands for network management

Image
Image
  1. ip

    … Multifunctional team for working with the network. Command

    ip address show

    displays information about network addresses,

    ip route

    manages routing and so on. Giving commands

    ip link set ethX up

    ,

    ip link set ethX down

    you can turn connections on and off. The team

    ip

    many uses, so before using it it is better to read the manual or enter

    ip --help

  2. ping

  3. … Shows whether you are connected to the network and helps determine the quality of the connection.

And something else

Image
Image

Finally, there are the main Linux commands. They display a cow that can talk to you (don't ask what the developers are using).

  1. cowsay whatever

  2. … The cow will say what you tell her.
  3. fortune | cowsay

  4. … The cow will give out a smart (or not so) thought or quote.
  5. cowsay -l

  6. … Lists all animals that can be displayed in the terminal. If you suddenly do not like cows.
  7. fortune | cowsay -f animal_from_list

  8. … The animal of your choice begins to shower with quotes, sometimes appropriate.
  9. sudo apt-get install fortunes fortune-mod fortunes-min fortunes-ru

  10. … Make the whole zoo speak Russian. Without this, animals are quoting Twain and Wilde in the original.

These are not all Linux commands. If you need to know in detail the options and how to use Linux commands, you can use the built-in tutorial. Dial

man your_command

or

your_command --help

Recommended: