Linux commands that can make a difference

Share

It doesn’t matter what you’re doing: SysAdmin, Developer, DevOps, or Ops… Linux and its tools are essential to your work! Here are a few commands that are frequently used in most tasks. Let’s start.

Utilities
rsync

Used to copy files and directories to a destination, like the cp command. Additionally, it allows copying to remote locations and provides a progress bar, which is often useful for backups.

# Example Usage
$ rsync -vap --ignore-existing
# Key flags:
v = verbrose, r = recursive, p = preserve permissions, g = group, o = owner, a = archive, --progress = progresss bar

mkpasswd

mkpasswd is a simple but very useful command that generates a complex random password at the specified length.

$ mkpasswd -l 8
> iwF1g2Lo

 screen

It is recommended to use when you are connected remotely, SSH and you do not want the running command (for example rsync) to be interrupted once the session is disconnected. Launched commands continue to run on the screen after the SSH session is interrupted/closed.

# Example Usage

$ screen # Start a screen session

$ screen -ls # List running services

$ screen -r # Attach to session

Ldapsearch

Do you use LDAP server/database as infrastructure? Then Ldapsearch is a must. The tool opens a connection to an LDAP server and allows you to search, find and debug entries in your database.

# Example Usage

$ ldapsearch -x -W -D <username | less

# Key Flags

-x = simple authentication, -W = prompt for password, -D = Use distinguished binddn name to bind to LDAP directory

Uptime

Uptime returns metrics on how long a server has been running, the current time, the number of users, and memory usage averages. If something goes wrong on your server, this is often the first port of call.

Wall

Using it, you can send a message to all the users logged into the system and let them know about changes you plan to make.

$ wall "Maintenance scheduled for 14:30"

Broadcast message from Moe@localhost: Maintenance scheduled for 14:30

Top

Displays an auto-refreshing list of processes for the CPU and critical memory use and CPU usage metrics.

$ top

Ncdu

The ncdu command provides a quick, convenient view for disk usage. This command allows you to quickly and easily determine which directories are taking up the most space on your hard drive.

$ ncdu

lsof

lsof is a single command used for one fundamental purpose: LiSt Open Files. This is especially useful when experiencing mounting problems that say files are being used. This command quickly identifies which files are in use by which processes.

$ lsof

Netcat

It is an excellent network utility tool that system administrators can use for any task in the networking area (Netcat or nc is mainly used for port scanning). Netcat can support port scanning, file copying, port forwarding, proxy servers, and hosting servers … it’s incredibly versatile!

# Example Usage:

$ nc -vz <host> <port> # Checks the connection between two hosts on a given port

$ nc -l 8080 | nc <host> 80 # Creating a proxy server

NetStat

Netstat returns various network details such as routing tables, network connections, memberships, stats, flags, etc.

# Example Usage

$ netstat -a # List all network ports

$ netstat -tlpn # List all listening ports

# Key Flags

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

Nslookup

Get information about servers on the internet or your local network. It queries DNS to find the name server information and can be useful for network debugging.

# Example Usage

$ nslookup ropardo.ro/tags/devops

# Key Flags

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

TCPDump

Capture and analyze traffic coming to and from your system. Debugging and troubleshooting network issues can be difficult, but using a potent and versatile tool like TCPDump makes the task manageable. It can also be used as a security tool.

# Example Usage

$ tcpdump

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

I hope you can take some benefit from this list. Thanks to Linux’s popularity, mastering Linux can be extremely useful.

Tags:

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close