Some Important Commands Used In Linux/Unix

Some Important Commands Used In Linux/Unix


This post was last updated on August 3rd, 2020 at 02:51 pm

Command-line interface(CLI) is a way that allows users to interact with computer programs through commands. A user issues commands to a program which gets interpreted by a command-line interpreter. Most operating system implements CLI in the form of shells that are used for interactive access of the various services or functions of the operating system. CLI has its own benefits over a graphical user interface(GUI). The command-line interface is more efficient than a GUI. A program can be accessed through CLI, which is not accessible on GUI. So in this article we are going to discuss some important commands that are used in Linux/Unix terminal frequently.

File commands –

lsList files and directories under the current working directory
pwdShow the path of the current working directory
mkdir dir(s)Make a directory with name dir
cd dirChange directory to dir
cdChange the current directory to home directory
rm -r dir(s)Remove or delete the directory dir
rm -rf dir(s)Delete the directory dir forcefully
touch file(s)Create a file
rm file(s)Delete the file
rm -f file(s)Delete the file forcefully
cat >filePlace the standard input into the file
cp file1 file2Copy the content of file1 to file2
cp -r dir1 dir2Copy the directory dir1 to dir2
mv file_or_directory dirMove a file or directory to directory dir

System info commands –

dateShow the current date and time
calShow the month’s calendar
uptimeShow the current uptime(total time of the current session since you log in)
wDisplay who is online
whoamiDisplay who are you logged in as
uname -aDisplay the kernel information
finger user_nameDisplay about the user
man commandDisplay the manual for the given command
dfShow the disk usage and other related information
duShow directory space usage
freeShow the physical memory and swap usage
cat /proc/cpuinfoDisplay Cpu information
cat /proc/meminfoDisplay Memory information

File/directory searching commands –

grep patternSearch for patterns in a file
grep -r pattern dirSearch recursively for a pattern in dir
command | grep patternSearch pattern in the output of a command
locate fileDisplay the path of the file with other file having a similar name
find .-name filenameSearches in the current directory and below it for files and directories with the names starting with filename
pgrep patternSearches for all the named processes, that matches with the pattern and by default, it returns their process ID

Commands used in process management –

psDisplay the current working process
topDisplay the all running process with resource usage
kill pidKill the process with given process ID
killall -9 nameIf more than one process runs with that name, all of them will be killed
pkill patternKill the multiple process matches with pattern
bgResume a stopped job in the background
fgResume a stopped job in the foreground

Detailed use of process management commands with examples are given in a separate article. You should read process management in Linux/Unix.

File permission commands –

chmod octal file -Change the permission of file to octal, which can be found separately for user, group, world by adding, 4-read(r), 2-write(w), 1-execute(x). For detailed use of file permission commands, you should read this article file ownership and permissions in Linux/Unix.

Network commands –

ping hostPing the given host and output the result
whois domainDisplay the information about domain and its owner
dig domainDisplay DNS information for a domain
dig -x hostReverse lookup host
wget fileDownload file
wget -c fileContinue a stopped download

Compression commands –

tar cf file.tar file(s)Create tar named file.tar containing file
tar xf file.tarExtract the files from file.tar
tar czf file.tar.gz file(s)Create a tar with gzip compression
tar xzf file.tar.gzExtract a tar using Gzip
tar cjf file.tar.bz2 file(s)Create tar with Bzip2 compression
tar xjf file.tar.bz2Extract a tar using Bzip2
gzip fileCompress file and rename it to file.gz
gzip -d file.gzDecompress file.gz back to file


Shortcuts used in Linux/Unix terminal –

ctrl+cHalts the current command
ctrl+zSuspend the current command and can be resumed using fg or bg
ctrl+dLogout the current session
ctrl+wErases one word in the line
ctrl+uErases the whole line
ctrl+rType to bring up whole command or reverse search
!!Repeat the last command
exitLogout the current session


Previous How To Add/Remove A Software Repository In Linux?
Next How To Change Bootscreen Logo In Linux Mint?

About author

You might also like

Linux Topics 0 Comments

How to Copy Directory in Linux / Unix

This post was last updated on July 21st, 2020 at 01:10 pmIf you are looking to copy a directory in Linux using a command line, then here I have explained

Linux Topics 0 Comments

How To Hide Or Display Hidden Files/Directories In Linux?

This post was last updated on August 1st, 2020 at 01:56 pmLinux is a multiuser operating system that is getting popular day by day. Many new computer users start using

Linux Terminal 0 Comments

How To Mount And Unmount File Systems From The Linux Terminal?

This post was last updated on August 1st, 2020 at 12:13 pmIn Linux or Unix, mount command is used to mount(attach) a filesystem or storage device to a specific directory


No Comments Yet!

You can be first to comment this post!

Leave a Reply