Friday, June 14, 2024
HomeHow toLinux Commands - Overview and Examples

Linux Commands – Overview and Examples

The command line is one of the most powerful features of Linux. There exists a sea of Linux command line tools, allowing you to do almost everything you can think of doing on your Linux PC. However, this usually creates a problem: with so many commands available to use, you don’t know where and how to start learning them, especially when you are a beginner. 

If you are facing this issue, and are looking for an easy way to start off your command line journey in Linux, you’ve come to the correct place, in this article, we will introduce you to a host of popular and useful Linux commands. The article is organized in a way that you will quickly learn what each command does through an easy-to-understand example. To learn more about a command, click on the ‘More…’ link at the end of its explanation.


The adduser and addgroup commands lets you add a new user and group to a system, respectively. Here’s an example for adduser:

$ sudo adduser testuser
Adding user `testuser' ...
Adding new group `testuser' (1003) ...
Adding new user `testuser' (1003) with group `testuser' ...
Creating home directory `/home/testuser' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:

Read more:


The apropos command is used to quickly search the names and descriptions of all available man pages. Examples: Search for all man pages for the postfix program:

$ apropos postfix

Read more:


The aspell command lets you perform a spell check on a text file. Example to run a spell check on the text file test.txt:

$ aspell -c test.txt

Have a look at this tutorial for an in-depth introduction to the aspell command:


The ar command allows you to create, modify, or extract archives. Example on how to list files from ‘test.a’ archive:

$ ar t test.a

Read more:


The arch command is used to print the machine’s architecture. For example:

$ arch

Not sure what ‘i686’ means? Head here.


The basename command allows you to strip off components from filenames that aren’t required. For Example:

basename NAME [SUFFIX]
basename OPTION... NAME...

More examples of basename command:


The bzip2 command is used to create compressed file archives in bzip2 format. Bzip2 has a better compression ratio than zip or gzip format.

$ bzip2 list.txt list1.txt list2.txt

More Examples:

Other commands to work with archive files in bzip2 format are bzcmp, bzdiff, bzmore, bzless, and bzgrep which are explained in this tutorial:


The cal and ncal commands display a calendar in the output.

$ cal
March 2017
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
$ ncal
March 2017
Su 5 12 19 26
Mo 6 13 20 27
Tu 7 14 21 28
We 1 8 15 22 29
Th 2 9 16 23 30
Fr 3 10 17 24 31
Sa 4 11 18 25

More examples of the cal and ncal commands:


The cat command allows you to concatenate files, or data provided on standard input, and print it on the standard output. In layman’s terms, the command prints the information provided to it, whether through stdin or in the form of a file.

$ cat test.txt are you?

More CAT command examples:


The cd command is used to change user’s present working directory.

$ cd /home/himanshu/

More CD command examples:


The chattr command is used to list and edit extended filesystem attributes for files and folders like the immutable attribute. This example shows how to make a file immutable so that no Linux user, not even the root user, can edit or remove it without removing the immutable attribute first.

chattr +i /path/somefile.txt

The immutable attribute is removed with:

chattr -i /path/somefile.txt

More examples for the chattr command are shown in this tutorial:


The chgrp command allows you to change the group ownership of a file. The command expects new group name as its first argument and the name of file (whose group is being changed) as second argument.

$ chgrp howtoforge test.txt

More: Linux Chgrp Command for Beginners (5 Examples)


The chmod command lets you change access permissions for a file. For example, if you have a binary file (say helloWorld), and you want to make it executable, you can run the following command:

chmod +x helloWorld

More: Linux chmod command tutorial for beginners


The chown command allows you to change the ownership and group of a file. For example, to change the owner of a file test.txt to root, as well as set its group as root, execute the following command: 

chown root:root test.txt

More: Linux Chown Command Tutorial for Beginners (7 Examples)


The cksum command prints the CRC checksum and byte count for the input file. 

$ cksum test.txt
3741370333 20 test.txt

Not sure what checksum is? Head here.

More about the Chksum command: Linux cksum command explained for beginners (with examples)


The clear command is used to clear the terminal screen.

$ clear

More: Linux clear command tutorial for beginners (3 examples)


The cmp command is used to perform byte-by-byte comparison of two files.

$ cmp file1 file2
file1 file2 differ: byte 1, line 1

More CMP command examples:


The comm command is used to compare two sorted files line-by-line. For example, if ‘file1’ contains numbers 1-5 and ‘file2’ contains number 4-8, here’s what the ‘comm’ command produces in this case:

$ comm file1 file2


The cp command is used for copying files and directories.

$ cp test.txt /home//himanshu/Desktop/

More: Linux cp command tutorial for beginners (8 examples)


Cpulimit is a tool which limits the CPU usage of a process (expressed in percentage, not in CPU time). It is useful to control batch jobs when you don’t want them to eat too many CPU cycles. The goal of cpulimit is to prevent a process from running for more than a specified time ratio. 

$  cpulimit -l 30 dd if=/dev/zero of=/dev/null &

More: How to limit CPU usage with CPULimit on Ubuntu Linux


The csh command is used to switch between Linux user shells. To switch from your default shell (probably /bin/bash) to /bin/sh, use this command:

$ chsh -s /bin/sh

More: Linux chsh Command Tutorial for Beginners (5 Examples)


The csplit command lets you split a file into sections determined by context lines. For example, to split a file into two where the first part contains ‘n-1’ lines and the second contains the rest, use the following command:

$ csplit file1 [n]

The two parts are saved as files with names ‘xx00’ and ‘xx01’, respectively.

More: Linux Csplit Command Explained for Beginners (6 Examples)


The curl command is used to download files from the internet by HTTP or HTTPS. Example to fetch an Ubuntu torrent file and save it as test.torrent in the current directory:

$ curl > test.torrent

See here for more examples with useful curl command line options:


The date command can be used to print (or even set) the system date and time.

$ date
Tue Feb 28 17:14:57 IST 2017

More: Linux Date Command Tutorial for Beginners (8 Examples)


The dd command copies a file, converting and formatting it according to the operands. For example, the following command creates an image of /dev/sda partition.

dd if=/dev/sda of=/tmp/dev-sda-part.img

More: Linux dd command explained for beginners (8 examples)


The df command displays the file system disk space usage in output.

$ df /dev/sda1
Filesystem 1K-blocks Used     Available Use% Mounted on
/dev/sda1  74985616  48138832 23014620  68%     /

More: Linux df Command Tutorial for Beginners (8 Examples)


The diff command lets you compare two files line by line.

$ diff file1 file2


The diff3 command, as the name suggests, allows you to compare three files line by line.

$ diff3 file1 file2 file3


The dig command is used to query DNS servers and to resolve DNS records. Example to get the IP address and information about the name servers of the domain

$ dig

More examples on how to resolve domain names and DNS records with the dig command:


The dir command lists directory contents. For example:

$ dir
test1 test2 test.7z

More: Linux dir command for beginners (10 examples)


The dirname command strips last component from a file name/path. In layman’s terms, you can think of it as a tool that, for example, removes file name from the file’s absolute path.

$ dirname /home/himanshu/file1

More: Linux dirname command explained for beginners (4 examples)


The dmesg command lets you print or control the kernel ring buffer. Following is its syntax:

dmesg [options]

More: Linux dmesg Command Tutorial for Beginners (5 Examples)


The dmidecode command prints a system’s DMI (aka SMBIOS) table contents in a human-readable format.

$ sudo dmidecode
# dmidecode 2.12
SMBIOS 2.6 present.
50 structures occupying 2056 bytes.
Table at 0x000FCCA0.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: American Megatrends Inc.
Version: 080015
Release Date: 08/22/2011


The dpkg tool is basically a package manager for Debian/Debian-based systems. Following is its syntax:



dpkg [options] filename

More: Linux dpkg Command Tutorial for Beginners (8 Examples)


The du command displays disk usage of files present in a directory as well as its sub-directories.

$ du /home/himanshu/Desktop/
92 /home/himanshu/Desktop/Downloads/meld/meld/ui
88 /home/himanshu/Desktop/Downloads/meld/meld/vc
56 /home/himanshu/Desktop/Downloads/meld/meld/matchers
12 /home/himanshu/Desktop/Downloads/meld/meld/__pycache__
688 /home/himanshu/Desktop/Downloads/meld/meld
16 /home/himanshu/Desktop/Downloads/meld/bin
328 /home/himanshu/Desktop/Downloads/meld/data/ui
52 /home/himanshu/Desktop/Downloads/meld/data/icons/svg

More: Linux du Command Tutorial for Beginners (10 Examples)


The echo command displays whatever input text is given to it.

$ echo hello hi
hello hi

More: Linux echo Command Tutorial for Beginners (5 Examples)


ed is a line-oriented text editor. 

$ ed


The eject command lets you eject removable media (typically, a CD ROM or floppy disk)

$ eject


The env command not only displays the current environment but also lets you edit it.

$ env

More: Linux env Command Tutorial For Beginners (5 Examples)


The exit command causes the shell to exit.

$ exit

More: Linux exit Command Explained for Beginners (With Examples)


The expand command converts tabs present in the input file(s) into spaces and writes the file contents to standard output.

$ expand file1

More: Linux expand Command Tutorial For Beginners (with Examples)


The expr command evaluates expressions. For example:

$ expr 1 + 2

More: Linux expr command tutorial for beginners (with examples)


The factor command prints the prime factors of the input number.

$ factor 135
135: 3 3 3 5

More: Linux factor command tutorial for beginners (with examples)


The fgrep command is equivalent to the grep command when executed with the -F command line option. The tool is also known as fixed or fast grep as it doesn’t treat regular expression metacharacters as special, processing the information as a simple string instead.

For example, if you want to search for dot (.) in a file, and don’t want to grep to interpret it as a wildcard character, use fgrep in the following way:

$ fgrep "." [file-name]

More: Linux fgrep Command Tutorial for Beginners (with Examples)


The find command lets you search for files in a directory as well as its sub-directories.

$ find test*

More examples of the Linux Find command:


fmt is a simple optimal text formatter. It reformats each paragraph in the file passed to it and writes the file contents to standard output.

$ fmt file1

More: Linux fmt command – usage and examples


The fold command wraps each input line to fit in specified width.

$ fold -w 10
Hi my name is himanshu Arora
Hi my name
is himans
hu Arora

More: Linux fold command tutorial for beginners (with examples)


The free command displays the amount of free and used memory in the system.

$ free
       total           used  free   shared buffers cached
Mem:   1800032       1355288 444744 79440   9068   216236
-/+ buffers/cache: 1129984 670048
Swap:  1832956      995076  837880


The git command or git version control system has been developed by Linux Torvalds. It is currently the most popular software version control system which replaced the older SVN system. GIT is e.g. used at GitHub. Example of how to make a new git repository with the name ‘Mytest’ in the current directory:

$ git init Mytest

More on git command and how to connect it to GitHub can be found here:


The grep command searches for a specified pattern in a file (or files) and displays in output lines containing that pattern.

$ grep Hello test.txt are you?

More tutorials and examples for the Linux Grep command:


The groups command displays the name of groups a user is a part of.

$ groups himanshu
himanshu : himanshu adm cdrom sudo dip plugdev lpadmin sambashare

Read more:


The gzip command compresses the input file, replacing the file itself with one having a .gz extension.

$ gzip file1

More: Linux Gzip Command Tutorial for Beginners (7 Examples)


Files compressed with gzip command can be restored to their original form using the gunzip command.

$ gunzip file1.gz

Gunzip command examples in detail.

The head command displays the first 10 lines of the file to the standard output

$ head CHANGELOG.txt 
BEEBEEP (Secure Lan Messanger)
- Some GUI improvements (new icons, file sharing tree load faster)
- Always Beep on new message arrived (option)
- Favorite users (right click on user and enable star button) is on top of the list
- improved group usability
- Offline users can be removed from list (right click on an offline user in list and then remove)
- Clear all files shared (option)
- Load minimized at startup (option)

See here for more examples of the Linux head command.


The hostname command not only displays the system’s hostname, but lets them set it as well.

$ hostname

Read more:


The history command is used to display the history of commands that you typed in on the shell. It can be used to record and replay commands too. To view the command history, run:

$ history

See here for details on how to use history and how to record and replay commands.


The id command prints user and group information for the current user or specified username.

$ id himanshu
uid=1000(himanshu) gid=1000(himanshu) groups=1000(himanshu),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)

Read more:


The ifconfig command gives you the ability to configure network interfaces. Of course, you can also fetch information related to network interfaces with this tool. Following is its syntax:

ifconfig [-v] [-a] [-s] [interface]
ifconfig [-v] interface [aftype] options | address ...

More: Linux ifconfig Command Tutorial for Beginners (7 Examples)


The join command allows you to join lines of two files on a common field (default is first).

join [OPTION]... FILE1 FILE2

Want to learn more about this command? Head here.


The kill command, as the name suggests, helps the user kill a process by sending the TERM signal to it.

$ kill [process-id]

Five examples that show how to use the Linux kill command.


The killall command lets you kill a process by name. Unlike kill – which requires ID of the process to be killed – killall just requires the name of the process.

killall nautilus

Linux killall command examples.


The last command shows listing of last logged in users.

$ last
himanshu pts/11 :0 Thu Mar 2 09:46 still logged in
himanshu pts/1 :0 Thu Mar 2 09:46 still logged in
himanshu :0 :0 Thu Mar 2 09:42 still logged in
reboot system boot 4.4.0-62-generic Thu Mar 2 09:41 - 10:36 (00:54)
himanshu pts/14 :0 Wed Mar 1 15:17 - 15:52 (00:35)
himanshu pts/13 :0 Wed Mar 1 14:40 - down (08:06)

Read more:


The ldd command displays in output dependencies of a shared library.

$ ldd /lib/i386-linux-gnu/ => (0xb77df000) => /lib/i386-linux-gnu/ (0xb75da000)
/lib/ (0x80088000)

Examples on how to use the ldd command.


The ln command is used for creating links between files. For example, the following command would create a link named ‘lnk’ to a file with the name ‘test.txt’:

$ ln test.txt lnk

More examples on Linux ln command.


The less command in Linux is a powerful tool used primarily for viewing the contents of a text file, one page (or screen) at a time:

$ less filename.txt

More examples on Linux less command.


The locate command helps a user find a file by name.

$ locate [file-name]

Read more:


The logname command prints the user-name of the current user.

$ logname

Read more:


The look command in Linux displays lines beginning with a given string. Following is its syntax:

look [-bdf] [-t termchar] string [file ...]



The ls command lists contents of a directory in output.

$ ls progress
capture.png hlist.o progress progress.h sizes.c
hlist.c LICENSE progress.1 progress.o sizes.h
hlist.h Makefile progress.c sizes.o

More examples of the LS command:


The lshw command extracts and displays detailed information on the hardware configuration of the machine.

$ sudo lshw
[sudo] password for himanshu:
description: Desktop Computer
product: To Be Filled By O.E.M. (To Be Filled By O.E.M.)
vendor: To Be Filled By O.E.M.
version: To Be Filled By O.E.M.
serial: To Be Filled By O.E.M.
width: 32 bits
capabilities: smbios-2.6 dmi-2.6 smp-1.4 smp

Read more:


The lscpu command displays in the output system’s CPU architecture information (such as the number of CPUs, threads, cores, sockets, and more).

$ lscpu
Architecture: i686
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
Vendor ID: AuthenticAMD
CPU family: 16
Model: 6
Stepping: 3
CPU MHz: 2800.234
BogoMIPS: 5600.46
Virtualization: AMD-V
L1d cache: 64K
L1i cache: 64K
L2 cache: 1024K

Read more:


The lsof command displays information (on stdout) related to files opened by processes. Files can be of any type, including regular files, directories, block special files, character special files, executing text references, libraries, and stream/network files.


Read more:


man lets you access reference manuals for commands, programs/utilities, as well as functions.

$ man ls

Read more:


The md5sum command lets you print or check MD5 (128-bit) checksums.

$ md5sum test.txt
ac34b1f34803a6691ff8b732bb97fbba test.txt

Examples on how to use the Linux md5sum command and some more in the tutorial Linux md5sum command tutorial for beginners (5 examples).


The mkdir command lets you create directories.

$ mkdir [dir-name]

More examples for the mkdir command.


The mkfifo command is used to create named pipes.

$ mkfifo [pipe-name]


more is basically a filter for paging through text one screenful at a time.

$ cat [large-file] | more



The mv command lets you either move a file from one directory to another, or rename it.

$ mv test.txt /home/himanshu/Desktop/ 

More mv command examples.


The nano command in Linux launches the ‘nano’ editor. The editor is designed to emulate the features and user-friendliness of the UW Pico text editor.

$ nano


$ nano [file-name]

More about the Nano Editor:


The netstat command lets you print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. Example:

netstat [OPTIONS]

More: Linux netstat Command Tutorial for Beginners (8 Examples)


The nice command lets you run a program with modified scheduling priority.

$ nice -n[niceness-value] [program]
$ nice -n15 vim

Read more:


The nl command writes the contents of a file to output and prepends each line with a line number.

$ nl file1
1 Hi
2 How are you
3 Bye

Read more:


The nm command is used to display symbols from object files.

$ nm test
0804a020 B __bss_start
0804841d T compare
0804a020 b completed.6591
0804a018 D __data_start
0804a018 W data_start
08048360 t deregister_tm_clones
080483d0 t __do_global_dtors_aux
08049f0c t __do_global_dtors_aux_fini_array_entry
0804a01c D __dso_handle
08049f14 d _DYNAMIC
0804a020 D _edata
0804a024 B _end
080484e4 T _fini
080484f8 R _fp_hw
080483f0 t frame_dummy

Read more:


The nproc command displays the number of processing units available to the current process.

$ nproc

More examples:


The od command lets you dump files in octal as well as some other formats.

$ od /bin/ls
0000000 042577 043114 000401 000001 000000 000000 000000 000000
0000020 000002 000003 000001 000000 140101 004004 000064 000000
0000040 122104 000001 000000 000000 000064 000040 000011 000050
0000060 000034 000033 000006 000000 000064 000000 100064 004004
0000100 100064 004004 000440 000000 000440 000000 000005 000000
0000120 000004 000000 000003 000000 000524 000000 100524 004004


The passwd command is used for changing passwords for user accounts.

$ passwd himanshu
Changing password for himanshu.
(current) UNIX password:


The paste command lets you merge lines of files. For example, if ‘file1’ contains the following lines:

$ cat file1
My name is
Linux researcher
and tutorial

Then the following ‘paste’ command will join all the lines of the file:

$ paste -s file1
Hi My name is Himanshu Arora I Am a Linux researcher and tutorial writer

More examples of paste command.


The pidof command gives you the process ID of a running program/process.

$ pidof nautilus


The ping command is used to check whether or not a system is up and responding. It sends ICMP ECHO_REQUEST to network hosts.

$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=58 time=47.3 ms
64 bytes from icmp_seq=2 ttl=58 time=51.9 ms
64 bytes from icmp_seq=3 ttl=58 time=57.4 ms

More: Linux ping Command Tutorial for Beginners (8 Examples)


The ps command displays information (in the form of a snapshot) about the currently active processes.

$ ps
4537 pts/1 00:00:00 bash
20592 pts/1 00:00:00 ps


The pstree command produces information about running processes in the form of a tree.

$ pstree
? ??dnsmasq
? ??3*[{NetworkManager}]


The pwd command displays the name of the current/working directory.

$ pwd

More Examples:


The rm command lets you remove files and/or directories.

$ rm [file-name]

Detailed examples for the Linux rm command.


The rmdir command allows you to delete empty directories.

$ rmdir [dir-name]

Examples on Linux rmdir command.


The scp command lets you securely copy files between systems on a network.

$ scp [name-and-path-of-file-to-transfer] [user]@[host]:[dest-path]


The screen command helps you to keep a terminal session open even when your SSH connection is interrupted.

$ screen

Detailed examples can be found here: Linux screen Command: Keep Processes Running Despite a Dropped Connection


The sdiff command lets you perform a side-by-side merge of differences between two files.

$ sdiff file1 file2



sed is basically a  stream editor that allows users to perform basic text transformations on an input stream (a file or input from a pipeline).

$ echo "Welcome to Howtoforge" | sed -e 's/Howtoforge/HowtoForge/g'
Welcome to HowtoForge


The seq commands prints numbers from FIRST to LAST, in steps of INCREMENT. For example, if FIRST is 1, LAST is 10, and INCREMENT is 2, then here’s the output this command produces:

$ seq 1 2 10

Examples of how to use the Linux seq command.


The sha1sum command is used to print or check SHA1 (160-bit) checksums.

$ sha1sum test.txt
955e48dfc9256866b3e5138fcea5ea0406105e68 test.txt

Read more: Linux sha1sum Command Tutorial for Beginners (with Examples)


The shutdown command lets the user shut the system in a safe way.

$ shutdown

More examples:


The size command lists the section sizes as well as the total size for an object or archive file.

$ size test
text data bss dec hex filename
1204 280 4 1488 5d0 test

Examples for Linux size command.


The sleep command lets the user specify a delay for a specified amount of time. You can use it to delay an operation like:

$ sleep 10; shutdown


The sort command lets you sort lines of text files. For example, if ‘file2’ contains the following names:

$ cat file2

Then running the sort command produces the following output:

$ sort file2


The split command, as the name suggests, splits a file into fixed-size pieces. By default, files with names like xaa, xab, and xac are produced.

$ split [file-name]


ssh is basically OpenSSH SSH client. It provides secure encrypted communication between two untrusted hosts over an insecure network.

$ ssh [user-name]@[remote-server]


The ssh-keygen command is used to create a private/public key pair for SSH. Example of how to create an SSH key pair with 4096 bit:

$ ssh-keygen -o -b 4096 -t rsa

An in-depth explanation on how to use the ssh-keygen command can be found here:


The stat command displays the status related to a file or a file system.

$ stat test.txt
File: ‘test.txt’
Size: 20 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 284762 Links: 2
Access: (0664/-rw-rw-r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-03-03 12:41:27.791206947 +0530
Modify: 2017-02-28 16:05:15.952472926 +0530
Change: 2017-03-02 11:10:00.028548636 +0530
Birth: -

Read more:


The strings command displays in output printable character sequences that are at least 4 characters long. It is used to search for printable text (strings) in binary files. For example, when a binary executable ‘test’ was passed as an argument to this command, the following output was produced:

$ strings test
GCC: (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

Read more:


The su command lets you change user identity. Mostly, this command is used to become root or superuser.

$ su [user-name]


The sudo command lets a permitted user run a command as another user (usually root or superuser).

$ sudo [command]


The sum command prints checksum and block count for each input file.

$ sum readme.txt
45252 5

Read more:


The tac command prints input files in reverse. Functionality-wise, it does the reverse of what the cat command does.

$ cat file2
$ tac file2

Read more:


The tail command displays in the output the last 10 lines of a file.

$ tail [file-name]

Read more:


The talk command lets users talk with each other.

$ talk [user-name]


tar is an archiving utility that lets you create as well as extract archive files. For example, to create archive.tar from files ‘foo’ and ‘bar’, use the following command:

tar -cf archive.tar foo bar



The tee command reads from standard input and writes to standard output as well as files.

$ uname | tee file2
$ cat file2

Examples of Linux tee command.


The test command checks file types and compare values. For example, you can use it in the following way:

$ test 7 -gt 5 && echo "true"

Read more:


The time command is used to summarize the system resource usage of a program. For example:

$ time ping
PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=52 time=44.2 ms
--- ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 44.288/44.288/44.288/0.000 ms
real 0m0.676s
user 0m0.000s
sys 0m0.000s


The top command gives a dynamic real-time view of a running system (in terms of its processes). For example:

$ top

More: Linux top Command Tutorial for Beginners (8 Examples)


The touch command lets you change file timestamps (the access and modification times). When the name of a non-existent file is passed as an argument, that file gets created.

$ touch [file-name]

More examples of Linux touch command.


The tr command can be used to translate/squeeze/delete characters. For example, here’s how you can use it to convert lowercase characters to uppercase:

$ echo 'howtoforge' | tr "[:lower:]" "[:upper:]"


The tty command prints the filename of the terminal connected to standard input.

$ tty

More: Linux tty Command Tutorial for Beginners (with Examples)


The uname command prints certain system information.

$ uname -a
Linux himanshu-desktop 4.4.0-62-generic #83~14.04.1-Ubuntu SMP Wed Jan 18 18:10:26 UTC 2017 i686 athlon i686 GNU/Linux

Read more:


The unexpand command lets you convert spaces into tabs. Example:

unexpand [OPTION]... [FILE]...

Read More: Linux unexpand Command Explained for Beginners (with Examples)


The Uniq command is used to report or omit repeated lines. For example, if ‘file2’ contains the following data:

$ cat file2
Welcome to HowtoForge
Welcome to HowtoForge
A Linux tutorial website

Then you can use the uniq command to omit the repeated line.

$ uniq file2
Welcome to HowtoForge
A Linux tutorial website

Read more: Linux Uniq Command Tutorial for Beginners (10 examples)


The unexpand command converts spaces present in the input file(s) into tabs and writes the file contents to standard output.

$ unexpand file1


The uptime command tells how long the system has been running.

$ uptime
15:59:59 up 6:20, 4 users, load average: 0.81, 0.92, 0.82

Here are some examples of Linux uptime command usage.


The users command displays in the output the usernames of users currently logged in to the current host.

$ users
himanshu himanshu himanshu himanshu

Read more:


The vdir command lists information about the contents of a directory (the current directory by default).

$ vdir
total 1088
-rw-rw-r-- 1 himanshu himanshu 4850 May 20 2015 test_backup.pdf
-rw-rw-r-- 1 himanshu himanshu 2082 May 28 2015 test-filled.pdf
-rw-rw-r-- 1 himanshu himanshu 7101 May 28 2015 test.pdf 


vim is basically a text/programming editor. The name ‘vim’ stands for Vi IMproved as the editor is upwards compatible with the Vi editor.

$ vim [file-name]

Take a look here for a tutorial that shows editing files with vim on the command line explained in detail.


The w command displays information about the users currently on the machine and their processes.

$ w
16:18:07 up 6:39, 4 users, load average: 0.07, 0.32, 0.53
himanshu :0 :0 09:39 ?xdm? 1:08m 0.25s init --user
himanshu pts/0 :0 09:41 6:36m 0.84s 7.84s gnome-terminal
himanshu pts/10 :0 14:51 0.00s 0.16s 0.00s w
himanshu pts/11 :0 15:41 35:19 0.05s 0.05s bash

Read more:


The wall command lets you write and send a message to other users that are currently logged in.

$ wall [your-message]

Read more:


The watch command can be used to monitor a program’s output. It runs the program repeatedly, displaying its output and errors. For example:

$ watch date

Read more:


The wc command prints newline, word, and byte counts for a file.

$ wc test.txt
0 3 20 test.txt

Read more about the Linux wc command.


The wget command line tool in Linux lets you perform a non-interactive download of files from the Web.

Here’s how you can use it:

wget [URL]

Read more about the wget command here.


The whatis command displays single-line manual page descriptions.

$ whatis mkdir
mkdir (1) - make directories
mkdir (2) - create a directory
mkdir (1posix) - make directories


The which command basically lets you locate a command – the file and the path of the file that gets executed. For example:

$ which date

Read more:


The who command shows who is logged on.

$ who
himanshu :0 2017-03-03 09:39 (:0)
himanshu pts/0 2017-03-03 09:41 (:0)
himanshu pts/10 2017-03-03 14:51 (:0)
himanshu pts/11 2017-03-03 15:41 (:0)

Read more:


The whereis command shows in output locations of the binary, source, and manual page files for a command.

$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1posix.gz /usr/share/man/man1/ls.1.gz

Some Linux whereis command examples.


The whoami command prints the effective userid of the current user.

$ whoami

Read more:


The xargs command builds and executes command lines from standard input. In layman’s terms, it reads items from stdin and executes a command passed to it as an argument. For example, here’s how you can use xargs to find the word “Linux” in the files whose names are passed to it as input.

$ xargs grep "Linux"
file1:Linux researcher
file2:A Linux tutorial website
file3:Linux is opensource



The Yes command outputs a string repeatedly until killed.

$ yes [string]

More examples for Linux Yes Command.


The zcat command is used to display the content of gzip-compressed files. Example of how to display the content of the gzip compressed text file test.txt.gz:

$ zcat test2.txt.gz

More useful zcat examples can be found here:



Please enter your comment!
Please enter your name here

Most Popular