Hello guys, welcome back to my blog. In this article, I will discuss the top Linux commands for engineers, these Linux commands are very useful and are most commonly asked during interviews.
If you have any doubts related to electrical, electronics, and computer science, then ask questions. You can also catch me @ Instagram – Chetan Shidling.
In Linux, the shell (or terminal) is the lifeline of the coder or developer, and of any power user. Something that can be accomplished on the GUI (by clicking on various buttons), can be accomplished with much better efficiency on the terminal by utilizing commands. Maybe one can not recognize all the commands, but with everyday usage, one can readily recognize the most valuable ones. The following manual will teach you to the tiniest set of necessary commands needed to use your Linux computer efficiently.
File Commands
01.
ls
Directory listing
02.
ls -al
A formatted listing with hidden files
03.
ls -lt
Sorting the Formatted listing by time modification
04.
cd qemu
Change directory to qemu
05.
cd
Change to the home directory
06.
pwd
Show current working directory
07.
mkdir newfolder
Creating a directory dir
08.
cat >file
Places the standard input into the file
09.
more wget-log
Output the contents of the file
10.
head file.c
Output the first 10 lines of the file
11.
tail file.c
Output the last 10 lines of the file
12.
tail -f file.c
Output the contents of the file as it grows, starting with the last 10 lines
13.
touch file
Create or update file
14.
rm file
Deleting the file
15.
rm -r newfolder
Deleting the directory
16.
rm -f file
Force to remove the file
17.
rm -rf dir
Force to remove the directory dir
18.
cp file1 file2
Copy the contents of file1 to file2
19.
cp -r dir1 dir2
Copy dir1 to dir2; create dir2 if not present
20.
mv file1 file2
Rename or move file1 to file2, if file2 is an existing directory
21.
ln -s file1 link
Create symbolic link, link to file
Process management
01.
ps
To display the current working processes
02.
top
Display all running process
03.
kill pid
Kill the process with given pid
04.
killall proc
Kill all the process named proc
05.
pkill pattern
Will kill all processes matching the pattern
06.
bg
The list stopped or background jobs, resume a stopped job in the background
07.
fg
Brings the most recent job to the foreground
08.
fg n
Brings job n to the foreground
Searching
01.
grep pattern file
Search for pattern in file. The grep filter searches a file for a spcific pattern of characters, and displays all lines that contain that pattern.
grep [options] pattern [files]
Options Description
-c : This prints only a count of the lines that match a pattern
-h : Display the matched lines, but do not display the filenames.
-i : Ignores, case for matching
-l : Displays list of a filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the pattern
-e exp : Specifies expression with this option. Can use multiple times.
-f file : Takes patterns from file, one per line.
-E : Treats pattern as an extended regular expression (ERE)
-w : Match whole word
-o : Print only the matched parts of a matching line,
with each such part on a separate output line.
-A n : Prints searched line and nlines after the result.
-B n : Prints searched line and n line before the result.
-C n : Prints searched line and n lines after before the result.
02.
grep -r pattern dir
Search recursively for pattern in dir
03.
command | grep pattern
Search pattern in the output of a command
04.
locate file
Find all instances of file
05.
find -name filename
Searches in the current directory (represented by a period) and below it, for files and directories with names starting with filename.
06.
pgrep pattern
Searches for all the named processes, that matches with the pattern and, by default, returns their ID
System Info
01.
date
Show the current date and time
02.
cal
Show this month’s calender
03.
uptime
Show current uptime
04.
w
Display who is on line
05.
whoami
Who you are logged in as
06.
finger user
Display information about user
07.
uname -a
Show kernel information
08.
df
Show the disk usage
09.
du
Show directory space usage
10.
free
Show memory and swap usage
Compression
01.
tar cf file.tar file
Create tar named file.tar containing file
02.
tar xf file.tar
Extract the files from file.tar
03.
tar czf file.tar.gz files
Create a tar with Gzip compression
04.
tar xzf file.tar.gz
Extract a tar using Gzip
05.
tar cjf file.tar.bz2
Create tar with Bzip2 compression
06.
tar xjf file.tar.bz2
Extract a tar using Bzip2
07.
gzip file
Compresses file and renames it to file.gz
08.
gzip -d file.gz
Decompresses file.gz back to file
Network
01.
ping host
Ping host and output results
02.
whois domain
Get whois information for domains
03.
dig domain
Get DNS information for domain
04.
dig -x host
Reverse lookup host
05.
wget file
Download file
06.
wget -c file
Continue a stopped download
Shortcuts
01.
ctrl+c
Halts the current command
02.
ctrl+z
Stops the current command, resume with fg in the foreground or bg in the background
03.
ctrl+d
Logout the current session, similar to exit
04.
ctrl+w
Erases one word in the current line
05.
ctrl+u
Erases the whole line
06.
ctrl+r
Type to bring up a recent command
07.
!!
Repeats the last command
08.
exit
Logout the current session
This was about ” Top Linux Commands For Engineers “. I hope this article ” Top Linux Commands For Engineers ” may help you all a lot. Thank you for reading.