Skip to Content

Linux Commands With Examples for Linux Beginners

Linux commands are the most powerful tools for Linux tasks. We collect the most useful Linux commands to help Linux beginners start.

Join our email group below. We can send you a free Linux account. You can use this account to login our cloud server and practice these commands.

  • ls command – lists contents of current working directory
  • cd command – change directory
  • touch command – create new file or directory
  • rm command – remove file or directory
  • mkdir command – create new directory
  • head command – print first few lines of a file
  • tail command – print last few lines of a file
  • echo command – print string
  • cat command – print contents of a file
  • cp command – copy file or directory
  • mv command – move file or directory

df command

Use the df command to see the available disk space in each of the partitions in your system. You can just type in df in the command line and you can see each mounted partition and their used/available space in % and in KBs. If you want it shown in megabytes, you can use the command “df -m”.

Get Your Free Linux training!

Join our free Linux training and discover the power of open-source technology. Enhance your skills and boost your career! Learn Linux for Free!

[howtouselinux@test ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/wbx_vg-root 51G 2.3G 49G 5% /
devtmpfs 189G 0 189G 0% /dev
tmpfs 189G 637M 189G 1% /dev/shm
tmpfs 189G 163M 189G 1% /run
tmpfs 189G 0 189G 0% /sys/fs/cgroup
/dev/sda1 2.0G 135M 1.9G 7% /boot

du command

Use du to know the disk usage of a file in your system. If you want to know the disk usage for a particular folder or file in Linux, you can type in the command du and the name of the folder or file.

[howtouselinux@test ~]$ du -sh /tmp/tcpdump_02791648.pcap
16M /tmp/tcpdump_02791648.pcap

hostname command

Use hostname to know your name on your host or network.

[howtouselinux@test ~]$ hostname
test

uname command

Use uname to show the information about the system your Linux distro is running. Using the command “uname -a” prints most of the information about the system. This prints the kernel release date, version, processor type, etc.

$ uname -a
Linux test 3.10.0-957.el7.x86_64 #1 SMP Thu Oct 4 20:48:51 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

ping command

Use ping to check your connection to a server.

$ ping 192.168.1.11
PING 192.168.1.11 (192.168.1.11) 56(84) bytes of data.
64 bytes from 192.168.1.11: icmp_seq=1 ttl=64 time=0.025 ms
64 bytes from 192.168.1.11: icmp_seq=2 ttl=64 time=0.025 ms
64 bytes from 192.168.1.11: icmp_seq=3 ttl=64 time=0.032 ms
64 bytes from 192.168.1.11: icmp_seq=4 ttl=64 time=0.025 ms

grep command

search the matches for the file

$ grep hello test
hello world

who command

display who is logged in

$ who
tocao pts/0 2020-11-09 09:51 (10.79.113.126)

ps command

report a snapshot of the current processes. List All Processes in Current Shell. If you run ps command without any arguments, it displays processes for the current.

$ ps
PID TTY TIME CMD
17765 pts/0 00:00:00 bash
23323 pts/0 00:00:00 ps

kill command

kill command is usually used to kill a process. Internally it sends a signal, and depending on what you want to do, there are different signals that you can send using this tool.

history command

history command is used to view the previously executed command

$ history
1 df -h
2 sudo sudo su –
3 hostname
4 man hostname
5 more /etc/hosts
6 systemctl status network
7 sudo sudo su –
8 exit