Linux is one of the most popular operating systems around the world. Whether you’re in IT as a Sysadmin, Developer, DevOps Manager, Security Specialist, or Ops Administrator, having a good understanding of Linux and its tools is an essential skill for you.

“A new survey has found that 47% of developers use a Linux-based operating system.”

I’ve read a lot of articles about Linux, but I found that most of them are targeted towards beginners and teach a handful of essential commands. This article will go over some commands that might be more advanced.

Utilities

rsync

Copying files to and from your computer with cp is easy. Copying files to a remote location such as Google Drive, OneDrive, or FTP is even easier. Copying an entire folder is even easier still – simply use the “rsync” command line flag.

# For example

$ rsync -vap –ignore-existing < source_file > < destination_file >

# Parameters:

v = verbrose, r = recursive, p = preserve permissions, g = group, o = owner, a = archive, –progress = progress bar

mkpasswd

mkpasswdis is a simple but useful command. It generates complex, random passwords that are the specified length.

$ mkpasswd -l 8

> iwF1g2Lo

screen

Screen is a popular terminal multiplexer. It’s best when you use it remotely using SSH, and you don’t want the network to die on you. Screen will keep executing Linux commands even if your SSH connection has gone down.

# For example

$ screen # Run session

$ screen -ls # Show running services

$ screen -r # Attach to session

Ldapsearch

Ldapsearch is a powerful Linux command for anyone who frequently works with LDAP databases. The Opener lets you search, find, and debug entries in the database without getting your hands on the LDAP server.

Monitoring Tool 

Uptime

This command will return metrics about how long the server has been running, current time/date, how many users are currently logged in, and the average memory usage of the server. Use this any time something goes wrong on your server in order to identify the problem.

The w- command only the letter w will provide information about the server uptime.

Wall

wall is a powerful command that allows you to send messages to all devices logged into the system. This can be useful when you need a mass notification, like a warning about an impending system failure.

$ wall “Information – It will be announced at 13:30” It is always scheduled for AnonyViet anonyvietl@localhost: Maintenance scheduled for 13 : 30

top

Command topDisplays a list of active CPU processes, RAM usage, and CPU usage metrics.

Ncdu

The command ncduprovides a convenient view of the hard disk usage. You can use it ncduto quickly and easily see which folders are using the most disk space.

lsof

lsofis a single command used for one basic purpose: Li S t O pen Files . This command quickly determines which files are being used by which processes.

Network-related commands – Network

Netcat

Netcator ncmainly is a network utility that can be used for scanning, port scanning, file copy, NAT Port, and proxy servers. Netcat has many features including Full Duplex TCP communication.

NetStat

netstatreturns various network details like routing table, network connection, membership, stats, flags etc

#For example

$ netstat -a # View network ports

$ netstat -tlpn # See the ports that are listening listening ports

# Parameters

-s = Show statistics, -v = verbrose, -r = show routing tables, -i display interface table, -g = show group memeberships

Nslookup

command can be used to find out how many servers are active on your internet or LAN. The command queries DNS to gather information about the said servers and can be useful as a debugging tool.

# Example Usage

$ nslookup media. com /tags/devops

# Key Flags

-port = Change the port number for the connection, -type = Change the query type. -domain = Set search list to name

TCPDump

We’ll gather data on traffic patterns to and from your system. tcpdumpis a versatile tool that offers powerful functions for network debugging and troubleshooting, but it can also be used as a security measure.

# Using

$ tcpdump

$ tcpdump -i < interface > < ipaddress or hostname > < port >

Ad-Hoc command

See beautiful JSON format

One of the hardest parts about working with JSON data on Terminal is viewing that data in a readable manner. As you can see below, even a small set of data displayed on the command line can quickly become difficult to read.

$ cat test. json

{ “title” : “Person” , “type” : “object” , “properties” : { “firstName” : { “type” : “string” } , “lastName” : { “type” : “string” } , “age” : { “description” : “Age in years” , “type” : “integer” , “minimum” : 0 }} ,”required” : [ “firstName” , “lastName”]}

By reading the JSON file in python, you will see the result appear nicer and easier to see.

$ cat test. json | python -m json. tool

{

“properties” : {

“age” : {

“description” : “Age in years” ,

“minimum” : 0 ,

“type” : “integer”

} ,

“firstName” : {

“type” : “string”

} ,

“lastName” : {

“type” : “string”

}

} ,

“required” : [

“firstName” ,

“lastName”

] ,

“title” : “Person” ,

“type” : “object”

}

Compare the results of two commands

Example comparing the results of 2 commands ls:

$ diff -u <(ls -l /directory/) <(ls -l /directory/) | colordiff

List all Systemd . services

systemctl -l -t service | less

Hopefully, the Linux commands above have helped you learn something new. Linux mastery is critical given its popularity, as it accounts for 96.3% of a million web hosts.

You have to wait 20sec.

Generating Working Code

Leave a Reply

Your email address will not be published. Required fields are marked *