Difference between revisions of "Top Linux Commands Part 1"

From Brian Nelson Ramblings
Jump to: navigation, search
(Created page with "==Top Linux Commands - Part 1== Thought I would make a list of the most useful Linux Commands used everyday. This is not a comprehensive list by any means, but this should g...")
 
(3) du - Find out how large files and directories are)
 
Line 35: Line 35:
 
The /var partition is almost file, find out what is using up the space
 
The /var partition is almost file, find out what is using up the space
  
  du -ha /var --max-depth=1
+
du -ha /var --max-depth=1
  
 
Our home directory is almost at quota, why?
 
Our home directory is almost at quota, why?
  
  du -ha /home/brian --max-depth=1
+
du -ha /home/brian --max-depth=1
 +
 
 +
Show only files and directories over 1GB
 +
 
 +
du -h --max-depth=5 /home/brian/ |egrep '[0-9]G\b'
  
 
===4) df - Find out if a partition is getting full===
 
===4) df - Find out if a partition is getting full===

Latest revision as of 14:00, 13 February 2014

Top Linux Commands - Part 1

Thought I would make a list of the most useful Linux Commands used everyday.

This is not a comprehensive list by any means, but this should give you a good start on some of the common Linux commands.

1) SSH - SSH is used to connect to remote terminals

Connecting to a remote server

ssh [email protected]

or

ssh -l brian briansnelson.com

Connecting over a different port

ssh -p 2020 -l brian briansnelson.com

2) Find - As you can guess to find files on a server

Location all files owned by a specific user and use ls to show the location and permissions

find / -group <groupname> -ls

Or Find which files have been changed in the last 5 days, (hacked sites)

find $PWD -mtime -5 -ls

Or save them to a text file for later use

find $PWD -mtime -5 -ls > ~/changedin5days.txt

3) du - Find out how large files and directories are

The /var partition is almost file, find out what is using up the space

du -ha /var --max-depth=1

Our home directory is almost at quota, why?

du -ha /home/brian --max-depth=1

Show only files and directories over 1GB

du -h --max-depth=5 /home/brian/ |egrep '[0-9]G\b'

4) df - Find out if a partition is getting full

This one is pretty basic, but you will find yourself using this command alot,

df -h 

Shows the size in human readable format

df -i

Sometimes, you reach max inodes before reaching max disk space.

df -T

Show the type of file system for each partition

5) grep - find lines within files

grep is a command you will use alot when trying to find hacked files or searching log files

Trying to debug an issue with a website and only want to see your hits

tail -f /var/log/httpd/transfer.log | grep <your ipaddress>

Or to check your traffic to the server

grep <your ipaddress> /var/log/httpd/transfer.log

I will update and create more lists of useful Linux Commands