A list of some important Linux commands part 2
A list of some important Linux commands part 2. In part 1 we learn about some basic commands such as cp, adduser, addgroup, arch, cal, date, cat, cd, etc. these all are the basic but important commands for Linux users that everyone should know. Now here is the second part in this we learn about some advanced commands such as dd, find, fmt, free, df, diff, diff3, dir, du, echo, eject, etc. but these commands are slightly on advance end beginners can’t understand all of them. So let’s start
The dd command in Linux is used for clone one hard disk to another hard disk. The dd command stands for “Disk Duplicator” and used for converting and copying data. This is a very useful and dangerous tool for the Linux operating system. Because it can use in many ways other than cloning of the hard disk. So we learn dd command in a detailed way in upcoming articles. Here the main use of dd command is given below that is the cloning of hard disk.
[email protected]:~# dd if=/dev/sda of=/dev/sdb
The df command is used to display the system disk space usage in output.
[email protected]:~# df /dev/sda Filesystem 1K-blocks Used Available Use% Mounted on udev 4078324 0 4078324 0% /dev
The diff command is used to compare two file line by line in Linux operating system.
[email protected]:~# diff a.txt b.txt 1,12c1,5 hiii hello how are you what the hell? i am fine what about you What the hell are going on here I think Its enough For today Rahul --- good morning everyone once again i am here with a new article [email protected]:~#
The diff3 command is used to compare three files line by line as the name suggests.
[email protected]:~# diff3 a.txt b.txt c.txt ==== 1:1,12c hiii hello how are you what the hell? i am fine what about you What the hell are going on here I think Its enough For today Rahul 2:1,5c good morning everyone once again i am here with a new article 3:1,3c hii everyone goodmorning
The dir command is used to list the directory contents. For example
[email protected]:~# dir Desktop Music Templates Downloads Documents Pictures satish Videos
The dirname command strips the last part of a given filename. This command removes the trailing/component from the NAME and prints the remaining portion. If it prints ‘.’ that means the current directory.
[email protected]:~# dirname Desktop/ . [email protected]:~# dirname Desktop/a.txt Desktop
The dmidecode command is used to prints the system’s DMI table contents in a human-readable format. This command is also used for getting Hardware information. For example:
[email protected]:~# dmidecode # dmidecode 3.1 Getting SMBIOS data from sysfs. SMBIOS 2.5 present. 10 structures occupying 449 bytes. Table at 0x000E1000. Handle 0x0000, DMI type 0, 20 bytes BIOS Information Vendor: innotek GmbH Version: VirtualBox Release Date: 12/01/2006 Address: 0xE0000 Runtime Size: 128 kB ROM Size: 128 kB Characteristics: ISA is supported PCI is supported Boot from CD is supported Selectable boot is supported 8042 keyboard services are supported (int 9h) CGA/mono video services are supported (int 10h) ACPI is supported Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: innotek GmbH Product Name: VirtualBox Version: 1.2 Serial Number: 0 UUID: 0E321BAC-7BA8-42F9-8DC0-599A50AF29F9 Wake-up Type: Power Switch SKU Number: Not Specified Family: Virtual Machine Handle 0x0008, DMI type 2, 15 bytes Base Board Information Manufacturer: Oracle Corporation Product Name: VirtualBox Version: 1.2 Serial Number: 0 Asset Tag: Not Specified Features: Board is a hosting board Location In Chassis: Not Specified Chassis Handle: 0x0003 Type: Motherboard Contained Object Handles: 0 Handle 0x0003, DMI type 3, 13 bytes Chassis Information Manufacturer: Oracle Corporation Type: Other Lock: Not Present Version: Not Specified Serial Number: Not Specified Asset Tag: Not Specified Boot-up State: Safe Power Supply State: Safe Thermal State: Safe Security Status: None Handle 0x0007, DMI type 126, 42 bytes Inactive Handle 0x0005, DMI type 126, 15 bytes Inactive Handle 0x0006, DMI type 126, 28 bytes Inactive Handle 0x0002, DMI type 11, 7 bytes OEM Strings String 1: vboxVer_5.2.4 String 2: vboxRev_119785 Handle 0x0008, DMI type 128, 8 bytes OEM-specific Type Header and Data: 80 08 08 00 BE 61 29 00 Handle 0xFEFF, DMI type 127, 4 bytes End Of Table
Want to send important data such as files and folders that you can’t send by email then here’s our guide on how you can send data between two computers using Teamviewer software.
The du command is used to displays the disk usages of files which is present in a directory as well as its sub-directories. For example:
[email protected]:~# du 8 ./.config/evolution/sources 12 ./.config/evolution 4 ./.config/goa-1.0 4 ./.config/systemd/user/sockets.target.wants 4 ./.config/systemd/user/default.target.wants 12 ./.config/systemd/user 16 ./.config/systemd 4 ./.config/enchant 8 ./.config/dconf 8 ./.config/gedit 4 ./.config/ibus/bus 8 ./.config/ibus 4 ./.config/gnome-session/saved-session 8 ./.config/gnome-session 84 ./.config/pulse 8 ./.config/nautilus 172 ./.config 4 ./Downloads 44 ./.vnc 4 ./Music 4 ./Pictures 624 ./.cache/gnome-software/3.26/extensions 96 ./.cache/gnome-software/3.26/ratings 724 ./.cache/gnome-software/3.26 728 ./.cache/gnome-software 936 ./.cache/gstreamer-1.0 4 ./.cache/evolution/sources/trash 8 ./.cache/evolution/sources 4 ./.cache/evolution/addressbook/trash 8 ./.cache/evolution/addressbook 4 ./.cache/evolution/calendar/trash 8 ./.cache/evolution/calendar 4 ./.cache/evolution/mail/trash 8 ./.cache/evolution/mail 4 ./.cache/evolution/memos/trash 8 ./.cache/evolution/memos 4 ./.cache/evolution/tasks/trash 8 ./.cache/evolution/tasks 52 ./.cache/evolution 4 ./.cache/obexd 4 ./.cache/folks/avatars 8 ./.cache/folks 9176 ./.cache/tracker 4 ./.cache/gnome-calculator 60 ./.cache/thumbnails/large 64 ./.cache/thumbnails 4 ./.cache/libgweather 10996 ./.cache 4 ./.gconf 4 ./Templates 4 ./Videos 4 ./.gnupg/private-keys-v1.d 8 ./.gnupg 24 ./Desktop/rahl 32 ./Desktop 4 ./Public 4 ./Documents 4 ./.local/share/evolution/addressbook/trash 4 ./.local/share/evolution/addressbook/system/photos 92 ./.local/share/evolution/addressbook/system 100 ./.local/share/evolution/addressbook 4 ./.local/share/evolution/calendar/trash 8 ./.local/share/evolution/calendar/system 16 ./.local/share/evolution/calendar 4 ./.local/share/evolution/mail/trash 8 ./.local/share/evolution/mail 4 ./.local/share/evolution/memos/trash 8 ./.local/share/evolution/memos 4 ./.local/share/evolution/tasks/trash 8 ./.local/share/evolution/tasks 144 ./.local/share/evolution 8 ./.local/share/gnome-shell 4 ./.local/share/sounds 12 ./.local/share/keyrings 4 ./.local/share/applications 76 ./.local/share/gvfs-metadata 4 ./.local/share/folks 436 ./.local/share/tracker/data 440 ./.local/share/tracker 4 ./.local/share/nautilus/scripts 8 ./.local/share/nautilus 4 ./.local/share/gnome-settings-daemon 988 ./.local/share/app-info/xmls 992 ./.local/share/app-info 4 ./.local/share/icc 1712 ./.local/share 1716 ./.local 13060 .
The echo command is used to display the content as output which is given to it as an input text. For example:
[email protected]:~# echo hello dear hello dear
The eject command is used to eject the removable disk such as floppy disk, and CD ROM.
[email protected]:~# eject
The env command is used to print a list of the current environment variables, or to run another program in a custom environment without modifying the current one.
[email protected]:~# env LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01; 31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31: *.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01; 31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01; 35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35: *.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*. nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35: *.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36: *.spx=00;36:*.xspf=00;36: SSH_CONNECTION=192.168.225.131 21528 192.168.225.211 22 LANG=en_US.UTF-8 S_COLORS=auto XDG_SESSION_ID=4 USER=root PWD=/root HOME=/root SSH_CLIENT=192.168.225.131 21528 22 SSH_TTY=/dev/pts/0 MAIL=/var/mail/root TERM=xterm SHELL=/bin/bash SHLVL=1 LOGNAME=root DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus XDG_RUNTIME_DIR=/run/user/0 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin _=/usr/bin/env OLDPWD=/root/Desktop
The exit command is used to close the terminal box.
[email protected]:~# exit
This command is used for copies files to the standard output because expansion will produce the content of the file in output with only tabs changed to spaces.
[email protected]:~# expand a.txt hiii hello how are you what the hell? i am fine what about you What the hell are going on here I think Its enough For today Rahul
The expr command is used to evaluate the arithmetic expression. such as if you want to know that the output of 5+4 is what then it can help you.
[email protected]:~# expr 5 + 4 9
The factor command is used to express the prime factors of the input number. for example:
[email protected]:~# factor 544 544: 2 2 2 2 2 17
This command is used for searching a string instead of searching for a pattern that matches an expression in a file.
[email protected]:~# fgrep "hello" a.txt hello
The find command is used to search any files in a directory as well as in its subdirectories also. For example:
[email protected]:~# find . -name a.txt ./a.txt ./Desktop/a.txt
This command is a formatter for simplifying and optimizing text files.
[email protected]:~# fmt a.txt hiii hello how are you what the hell? i am fine what about you What the hell are going on here I think Its enough For today Rahul
The fold command is used to wrap each input line to fit in specified width. For example:
[email protected]:~# fold -w 12 hi my name is satish meena. hi my name i s satish mee na.
The free command is used to display the amount of free memory and used memory in the system. For example:
[email protected]:~# free total used free shared buff/cache available Mem: 8182472 771524 6685192 152492 725756 6617384 Swap: 0 0 0
The groups command is used to displays the name of the groups a user is part of.
[email protected]:~# groups root
The gzip command is used to compress the input file and replace the input file itself with having a .gz extension.
[email protected]:~# gzip b.txt
The gunzip command is used to restore the compressed file into their original form.
[email protected]:~# gunzip b.txt.gz
The head command is used to displays the only first ten lines of the file to standard output. For example:
Sample output of a file is given below.
[email protected]:~# cat a.txt hiii hello how are you what the hell? i am fine what about you What the hell are going on here I think Its enough For today Rahul peanut
The output of the file after using the head command. Here you can observe that only the first 10 lines are shown as the output of the file.
[email protected]:~# head a.txt hiii hello how are you what the hell? i am fine what about you What the hell are going on here I think Its enough For today
These are some basic but important commands for Linux users that everyone should know about them. If you want to add some other commands then use the comment box for your thoughts.