Commands

As Linux is a command-line-based operating system, the use of commands is crucial for interacting with the system, performing tasks, and managing files and applications.

Here is a list of essential and useful commands:

  • Create a bash instance

bash

  • Exit from a bash instance

exit

  • See the manual/documentation or find a command

man $command
man -k $keyword        #Make a search of a command by a keyword
apropos $keyword       #Find a command by description

  • Clean up the console content

clear

  • Get information about users logged in

whoami #Shows the currently logged-in user
who    #Shows all logged-in users

  • Get the name of the computer


  • Get information about the machine and system

Information comes in the following order, separated by spaces:

  • Kernel name

  • Nodename

  • Kernel release

  • Kernel version

  • Machine architecture

  • Processor architecture

  • Hardware platform architecture

  • Operating system


  • Executes a command with superuser permissions


  • See user and group information


  • List files, directories, devices, and more

Hidden files start with a dot, for example .hiddenfile


  • Change the permissions of a file


  • Shows the actual working directory


  • Change the directory to the specified path


  • Get the path of the file by searching in the directories defined at the $PATH environment variable


  • Get the path of a file by searching in locate.db

locate.db is a built-in database of system files


  • Update locate.db manually


  • List sockets/services statistics


  • Use enviroment variables


  • List command history


  • Repeat a command based on the history


  • Open a file, usually graphic files such as images and PDFs


  • Assign a name for a simplified command or redefine a command


  • Output any text that we provide


  • Create a new directory


  • Show file content in the command line


  • Find a file or directory

The -permoption can receive permission, such as 777 or a=x


  • Count the number of entries in a file or output


  • Search through a file and show any entries with the specified value

Remembering the use of RegEx:

  • (a) -> Close and expression

  • [a-z] -> Indicates a class of characters (in this case, letters)

  • {1,10} -> Indicates how many times a pattern must be repeated (in this case, 1 to 10 times)

  • | -> Works as the OR logical operator

  • .* -> Works as the AND logical operator


  • Edit text and streams on output


  • Extract a section of text from the file


  • Sort lines of a file


  • Find unique occurrences in a file

uniq needs a sort file as input to work correctly


  • Compare the content of files

The first column of comm output represents unique lines for the first file, the second column represents the unique lines for the second file, and the third column represents the lines that both share


  • Shows the content of a file with replacements in the output


  • Format the output in columns


  • Encode or decode base64


  • Transform hex dump


  • Compress or extract files


  • Use data encryption


  • Create a file with the specified name


  • Delete a file or directory


  • Copy the content of a file into a new one


  • Move or rename a file


  • Shows the type of file


  • Execute a command at regular intervals


  • Change to the specified user


  • Create or edit a file through the command line

In Unix the ^ symbol represents the Ctrl key


  • Shows the estimated disk usage of a file


  • Make petitions to websites


  • Verify MD5 encryption for a file


  • Get and send files via SCP


  • Execute Python utilities


  • Get information about the system running processes


  • To kill a system process, we can send some signals to specify the type of killing

The process with a PID equal to 0 is a process that starts when the system boots


  • Manage system processes and services


  • Handle background processes

bg can only be used after stopping a process with ^z


  • Schedule to repeat a process as a crontab

Every user has only one crontab


  • Manage packages, repositories, and digital signatures from APT


  • Manage packages via Debian


  • Test if the connection to a remote resource is possible


  • Show the path a request takes as it heads to the target machine

A * symbol on the response represents that a package hasn't received an ICMP message from the router.


  • Gather information about with DNS lookups


  • Obtain the IP and record information from a domain


  • Query recursive DNS servers for the domain's information


  • Manage disk partition table


  • Network Utilities

When using netstat -p if the PID and name aren't shown, it's because the process is owned by another user. Running the command with sudo could show this information


  • List the capabilities of all binary files


  • Modify users, groups, and passwords

Last updated