CALL US

+91 9116117170

Updated Basic Linux Commands List 2019 | Cyberops Infosec

Updated Basic Linux Commands List 2019

By Palash Verma 0 Comment November 16, 2018

The Linux operating system is very popular with programmers and lovers of “poking around”, because it provides for the active use of the console, which contains hundreds of commands. If you decide to seriously take up the study of this flexible OS, you should first learn the basic commands in Linux .

Why do console commands exist in Linux ? Entering them into the console, the user can quickly perform a lot of actions: opening, moving and copying files, viewing various information and statistics, monitoring and debugging, obtaining detailed information about the system, modifying the software and visual parts of the system. And this is only part of the opportunities that you get, thanks to these commands.

Many have additional options, and some even do not work without them. To get started, just try typing commands into the console and study their effects.

The ability to modify the system with commands makes Linux a very universal operating system. You can customize it for yourself by changing everything in it. At first, the teams may seem complicated, but having learned them well, you will significantly speed up your work with the computer and begin to get real pleasure, understanding that everything in it is customized by you to your needs.

Remember that in order to fully work with the console you need administrator rights. Below is a list of basic commands in the Linux console and their decryption

LINUX FILE MANAGEMENT COMMANDS

LS

Utility to view 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 final directory. Useful options are -l ( List) and -a ( All). The first formats the output in the form of a list with more detailed information, and the second includes the display of hidden files.

CAT

Prints the contents of the file passed in the parameter to standard output. If you transfer multiple files, the team 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 ( Number) option .

CD

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

PWD

Prints the current directory. 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 the directory reference.

MKDIR

Create new directories. The most convenient option -p ( Parents), allows you to create the entire structure of subdirectories with one command, even if they do not already exist.

FILE

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

CP

Copying files and directories. It does not copy default directories recursively (that is, all subdirectories and all files in subdirectories), so do not forget to add the option -r ( Recursive) or -a ( Archive). The latter includes the mode of saving attributes, owner and temporary stamp in addition to recursive copying.

MV

Move or rename files and directories. It is noteworthy that in Linux it is the same operation. Renaming is moving a file to the same folder with a different name.

RM

Deletes files and folders. A very useful Linux command: with it, you can remove 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 the files in the basket, from which then everything can be restored, and completely erases. The actions of the rm operator are irreversible. Believe me, your excuses in the spirit of “rm ate my coursework” will not interest anyone.

 LN

Creates hard or symbolic links to files. Symbolic or programmatic links are something like Windows shortcuts. They provide a convenient way to access a specific file. Symbolic links point to a file, but have no metadata. Hard links, as opposed to symbolic ones, point to the physical address of the disk area where the file data is stored.

CHMOD

Changes file permissions. This is reading, writing and executing. Each user can change the rights for their files.

CHOWN

Changes the owner of the file. Only the superuser can change the owners. For recursive change, use the -R option.

FIND

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

LOCATE

Unlike find, the locate command searches the updatedb database for file name patterns. This database contains a snapshot of the file system, allowing you to search very quickly. But this search is unreliable because you cannot be sure that nothing has changed since the last snapshot.

DU

Shows the size of the file or directory. The most useful options are -h ( Human), which converts file sizes to an easily readable format, -s ( Summarize), which displays a minimum of data, and -d ( Depth), which sets the depth of recursion in directories.

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 an option -h that makes dimensions easy to read.

DD

As stated in the official manual, this is the terminal command for copying and converting files. Not very clear description, but that’s all that dd does. You give it a source file, a destination, and a couple of additional options. Then she makes a copy of one file to another. You can specify the exact size of the data to be written or copied. Works utility with all devices. For example, if you want to overwrite the hard disk with zeros from /dev/zero, you can do it. It is also often used to create LiveUSB or hybrid ISO images.

MOUNT/UMOUNT

These are the Linux console commands to connect and disconnect Linux file systems. You can connect everything from USB drives to ISO images. And only the superuser has rights to do this.

LINUX CONSOLE COMMANDS FOR WORKING WITH TEXT

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 the file, and it took your terminal emulator a few seconds to scroll through all the text. If your terminal does not support scrolling, you can do it with less. Less is newer than more and supports more options, so there’s no reason to use more.

HEAD/TAIL

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

GREP

Grep, like other Linux tools, does one action, but does it well: it searches for text by pattern. By default, it accepts standard input, but you can search in files. A pattern can be a string or a regular expression. It can output both matching and non-matching lines and their context. Every time you execute a command that gives out a lot of information, you do not need to analyze everything manually – let grep do its magic.

SORT

Sort lines of text by various criteria. The most useful options are -n (Numeric), by numeric value, and -r ( Reverse), which flips the output. This can be useful for sorting du output. For example, if you want to sort files by size, simply connect these commands.

WC

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

DIFF

Shows the differences between the two files in a line comparison. And only the lines in which differences are found are displayed. Changed lines are marked with a “c”, deleted – “d”, and new – “a”.

By the way, I have prepared another detailed article that describes exactly the contents of a text file in Linux using a terminal.

LINUX COMMANDS FOR MANAGING PROCESSES

KILL /XKILL/PKILL/KILLALL

Serve to complete processes. But they take different parameters to identify processes. Kill need the PID of the process, xkill – just click on the window to close it, killall and pkill accept the name of the process. Use the one that is convenient in a particular situation.

PS/PGREP

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

TOP/HTOP

Both commands are similar, both display processes and can be used as console system monitors. I recommend installing htop if it is not supplied by default in your distribution, as this is an improved version of top. You can not only view, but also control the processes through its interactive interface.

TIME

The time to complete the process. This is a stopwatch to run the program. Useful if you are wondering how much your implementation of the algorithm is lagging 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

SU/SUDO

Su and sudo are two ways to perform the same task: run the program on behalf of another user. Depending on your distribution, you probably use one or the other. But both work. The difference is that su switches you to another user, and sudo only executes the command on its behalf. Therefore, using sudo will be the safest way to work.

DATE

Unlike time, it does exactly what you expect from it: it displays the date and time to standard output. It can be formatted according to your needs: display the year, month, day, set the 12 or 24 hour format, get nanoseconds or the week number. For example, date + “% j% V” will display the day in the year and the week number in ISO format.

ALIAS

The command creates synonyms for other Linux commands. That is, you can make new teams or groups of teams, as well as rename existing ones. This is very useful for shortening long commands that you often use, or creating clearer names for commands that you use infrequently and cannot remember.

UPTIME

Tells you the running time of the system. Not very important information, but it can be useful for random calculations or just for the sake of interest, to find out how long the server has been restarted.

SLEEP

You are probably wondering how you can use it. Even without considering 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 USER MANAGEMENT COMMANDS

USERADD/USERDEL/USERMOD

These Linux console commands allow you to add, delete and modify user accounts. Most likely, you will not use them very often. Especially if it is a home computer, and you are the only user. You can manage users using a graphical interface, but it’s better to know about these commands just in case.

PASSWD

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

LINUX COMMANDS FOR VIEWING DOCUMENTATION

MAN/WHATIS

The man command opens the manual for a specific command. For all basic Linux commands, there are man pages. Whatis shows which sections of the manual are for this command.

WHEREIS

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

LINUX COMMANDS FOR NETWORK MANAGEMENT

IP

If the list of Linux commands for managing a network seems too short, you most likely 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 replaces one utility – ip. You can consider it as a Swiss army knife for working with a network or as an incomprehensible mass, but in any case, the future lies with it. Just get on with it.

PING

Ping is an ICMP ECHO_REQUEST datagram, but in fact it doesn’t matter. It is important that the ping utility can be a very useful diagnostic tool. It will help you quickly check whether you are connected to a router or to the Internet, and gives you some idea of ​​the quality of this connection.

NETHOGS

If you have a slow Internet, then you probably would be interested to know how much traffic some program uses in Linux or which program consumes all the speed. This can now be done using the nethogs utility. To specify a network interface, use the -i option.

TRACEROUTE

This is an improved version of ping. We can see not only the complete route of the network packets, but also the availability of the node, as well as the time of delivery of these packets to each of the nodes.

 

LINUX COMMANDS FOR MANAGING THE PACKAGE MANAGER

#apt (Debian/Ubuntu/Mint)

  1. sudo apt install <pkg_name>. Install the required package.
  2. sudo apt-add-repository <repo_name>. Add a third-party repository.
  3. sudo apt update. Update package information.
  4. sudo apt upgrade. Update all packages to the freshest (run after apt update).
  5. sudo apt remove <pkg_name>. Remove unwanted package.
  6. sudo apt purge <pkg_name>. Remove unnecessary package with all dependencies if you want to free up more space.
  7. sudo apt autoremove. Remove all unnecessary dependencies, abandoned packages and other garbage.

#dnf (Red Hat/Fedora/CentOS)

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

#pacman (Arch/Manjaro)

  1. sudo pacman -S <pkg_name>. Install the required package.
  2. sudo yaourt -S <pkg_name>. Install the package from the 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.
  5. sudo pacman -R <pkg_name>. Remove unwanted package.
  6. sudo pacman -Rs <pkg_name>. Remove unnecessary package with all dependencies.

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

#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 whose names start in the same way.

 

LINUX COMMANDS FOR MANAGING PARTITIONS

LSBLK

lsblk. This command shows which disks are on your system and which partitions they are divided into. The command also displays the names of your partitions and drives, in the format sda1, sda2, and so on.

MOUNT

mount. Mounts Linux drives, devices, or file systems so you can work with them. 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 connect anything: disks, external drives, partitions and even ISO images. This command needs to be executed with superuser rights. To mount an existing disk or partition, enter mount sdX.

UMOUNT

umount. Unmounts filesystems. The command umount sdXwill disable the external media file system so that you can extract it.

DD

dd. This command copies and converts files and sections. She has many different uses. For example, dd if=/dev/sda of=/dev/sdbmake an exact copy of the sda ​​partition on the sdb partition. dd if=/dev/zero of=/dev/sdXwill wipe the contents of the specified media with zeros so that the information cannot be restored. And dd if=~/Downloads/ubuntu.iso of=/dev/sdX bs=4Mmake a bootable media from the image you downloaded with the distribution.

LINUX COMMANDS TO CONTROL THE SYSTEM

DF

df. Displays the amount of your disk, and how much free space is left on it.

FREE

free. Displays the amount of available and used RAM.

UNAME

uname. Displays system information. If entered uname, the terminal will report only Linux. But the command uname -adisplays information about the computer name and kernel version.

UPTIME

uptime. Tells you how long your system is running.

WHEREIS

whereis. Displays the location of the executable file of the desired program.

WHOAMI

whoami. Calls the username.

These are not all Linux commands. If you need to know in detail the parameters and ways to use Linux commands, you can use the built-in guide. As I mentioned earlier use --help or man pkg_name this will help you a lot!

 

error: Content is protected by Cyberops !!