Useful Linux Commands for Sysadmins

These are some of the Linux command line commands I use, often on a daily basis, in my adventures as a sysadmin.

Find the largest files in a directory

Example – Find the 20 largest files in /var/www:

Replace /var/www with whatever directory you want to search in. Replace 20 with however many results you want to return.

Find and replace a string of text in a file

Example – Replace foo with bar in all text files in a directory:

Use brace expansion to tail multiple files

Example – tail Apache access and error log

Quickly change to your home directory

or

Change back to the last directory you were in

Re-run the previous command

Re-run the previous command as sudo

Get the IP of a hostname

Tunnel Traffic Over SSH

Once you enter your password, nothing will happen. This is because the -N switch
tells SSH to not open an interactive session

TIPS:
Use the -C switch to enable compression

Quickly share files via python’s simplehttpserver

Example – Start a server on port 8080 to share files in the /tmp/foo/ directory:

What are your favorite commands?

What are some commands that you use on a regular basis? Leave a comment below to let everyone know!

Leave a Reply

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

×Mike Everhart

Need Some More Help? Let's Talk!

I'd love to work with you! Fill out the form below to schedule a free consultation to discuss your needs and how I can help.

Need More Help?