Most common Linux Commands

Linux provides a diverse range of commands, bellow is a list of the most relevant commands.

alias

Gives a specific name to a command or sequence of commands.

alias cls=clear
alias pf="ps -e | grep 1"</code></pre> <!-- /wp:code -->  <!-- wp:heading --> <h2>cat</h2> <!-- /wp:heading -->  <!-- wp:paragraph --> Faster lists the contents of files to the terminal window.   <!-- /wp:paragraph -->  <!-- wp:code --> <pre class="wp-block-code"><code>cat .bash_logout</code></pre> <!-- /wp:code -->  <!-- wp:heading --> <h2>cd</h2> <!-- /wp:heading -->  <!-- wp:paragraph --> Changes the current directory. <!-- /wp:paragraph -->  <!-- wp:code --> <pre class="wp-block-code"><code>cd work cd ~ cd ../games</code></pre> <!-- /wp:code -->  <!-- wp:heading --> <h2>chmod</h2> <!-- /wp:heading -->  <!-- wp:paragraph --> File/Folder permission plags setup. <!-- /wp:paragraph -->  <!-- wp:code --> <pre class="wp-block-code"><code>-rwxrwxrwx</code></pre> <!-- /wp:code -->  <!-- wp:paragraph --> '-' for a file, 'd' for directory, <code>'r'</code>  read, '<code>w'</code> write, '<code>x'</code> stands for execute.    <!-- /wp:paragraph -->  <!-- wp:code --> <pre class="wp-block-code"><code>0: No permission 1: Execute permission 2: Write permission 3: Write and execute permissions 4: Read permission 5: Read and execute permissions 6: Read and write permissions 7: Read, write and execute permissions</code></pre> <!-- /wp:code -->  <!-- wp:code --> <pre class="wp-block-code"><code>chmod -R 765 example.txt</code></pre> <!-- /wp:code -->  <!-- wp:heading --> <h2>chown</h2> <!-- /wp:heading -->  <!-- wp:paragraph --> Changes the owner and group owner of a file. <!-- /wp:paragraph -->  <!-- wp:code --> <pre class="wp-block-code"><code>sudo chown dave:mary example.txt</code></pre> <!-- /wp:code -->  <!-- wp:heading --> <h2>curl</h2> <!-- /wp:heading -->  <!-- wp:paragraph --> Retrieves information and files from Uniform Resource Locators (URLs) or internet addresses. <!-- /wp:paragraph -->  <!-- wp:code --> <pre class="wp-block-code"><code>curl https://github.com/ayoubbensakhria/core.c -o core.c</code></pre> <!-- /wp:code -->  <!-- wp:paragraph --> -o for output. -s for silent mode (you don't want to see the information). <!-- /wp:paragraph -->  <!-- wp:heading --> <h2>df</h2> <!-- /wp:heading -->  <!-- wp:paragraph --> Displays the size, used space, and available space on the mounted filesystems of your computer. <!-- /wp:paragraph -->  <!-- wp:code --> <pre class="wp-block-code"><code>df -h -x squashfs</code></pre> <!-- /wp:code -->  <!-- wp:paragraph --> -h for human readable. -x for exclude. <!-- /wp:paragraph -->  <!-- wp:heading --> <h2>diff</h2> <!-- /wp:heading -->  <!-- wp:paragraph --> Shows the differences between two text files. <!-- /wp:paragraph -->  <!-- wp:code --> <pre class="wp-block-code"><code>diff -y -W 70 alpha1.txt alpha2.txt --suppress-common-lines</code></pre> <!-- /wp:code -->  <!-- wp:paragraph --> -y for side by side. -w for the width. <!-- /wp:paragraph -->  <!-- wp:heading --> <h2>echo</h2> <!-- /wp:heading -->  <!-- wp:paragraph --> Prints a string of text to the terminal window. <!-- /wp:paragraph -->  <!-- wp:code --> <pre class="wp-block-code"><code>echoPATH

exit

Exit an ssl session.

find

Finds file location.

find . -name *ones*
find . -type f -name *ones*
find . -iname *wild*

. matches the current folder. -name *ones* the file name contains the string ‘ones’, -iname not a case sensitive search.

finger

Get user information.

free

Current memory usage.

free -h

grep

Searches lines that contains a specific string.

grep train *.txt

groups

Get a user’s group.

groups ayoub

gzip

Files compression.

gzip -k core.c

-k for keep.

head

Returns the first 10 lines of a file.

head -n 5 core.c

-n for more lines.

history

Shows the history of the used commands.

history
!19
!!

!19 use the command 19 displayed in the history. !! use the last command.

kill

Terminate a process.

ps -e | grep shutter
kill 1692

less

 View files without opening an editor.

less core.c

ls

Lists the files and folders in a specific directory.

ls -lha

-l for long files, h human friendly, a hidden files.

man

Displays user manual pages in less mode.

man chown

mkdir

Creates a new directory.

mkdir -p quotes/yearly/2019

-p for parents (creates parents too).

mv

Moves files and directories.

mv ~/Documents/manuals/Apache.pdf ./The_Shadows_Apache.pdf

passwd

Change user password.

sudo passwd ayoub

ping

Verifies current network connectivity with another network.

ping -c 3 -a 8.8.8.8

-c for attempts, -a to hear a ping.

ps

Lists current running processes

ps -u dave | less
ps -e | less

-u for a particular user, -e for every process.

pwd

Current working directory.

shutdown

shutdown +15 Shutting down in 15 minutes!
shutdown -c

-c to cancel shutdown.

SSH

Allows to establish a connection to a remote Linux computer.

ssh ayoub@192.168.4.23

sudo

For actions that require root access.

sudo passwd ayoub

tail

List the first 10 (default) or n lines of a file.

tail -n 5 core.c

tar

Creates a tarball archive file.

tar -cvzf songs.tar.gz ayoub/

-c for create, -v for verbose, -f for file, z (gzip) for compression. j (bzip2) for superior compression algorithm.

top

Displays the current machine realtime data and information.

uname

Displays current system information. -a for all, -s -r -v for kernel name, release, and version.

whoami

Determines whether you’re logged or not.

w

Displays current logged users.

Don’t miss these tips!

We don’t spam! Read our privacy policy for more info.

Open chat
Powered by