Difference between revisions of "Linux Commands"
Line 1: | Line 1: | ||
Useful Linux Commands | Useful Linux Commands | ||
− | + | You can use <code>man [command]</code> to get information about a command, but that is more programmer-centric. You are generally better off going to a search engine and searching for <code>[command] examples</code>. | |
− | + | ==Disk Commands== | |
+ | |||
+ | Returns a quick overview of what disks are mounted and how full they are in human readable formatting. | ||
df -h | df -h | ||
+ | ==Directory Commands== | ||
− | + | ===Directory details=== | |
+ | Returns a total size of the directories under where this command was run and sorts by size. Warning: May take a long time. | ||
du -hsx * | sort -rh | head -10 | du -hsx * | sort -rh | head -10 | ||
− | + | ===File List=== | |
− | ==List | + | Return a list of files in a directory. This always works (shows file size in bytes) |
− | This always works ( | + | |
ls -s | ls -s | ||
Line 27: | Line 30: | ||
l -trh | l -trh | ||
− | == | + | ===Create a directory=== |
+ | md [directory name] | ||
+ | mkdir [directory name] | ||
− | + | ==File Commands== | |
− | + | ||
− | + | ===Find a file=== | |
− | ==Find a file == | + | |
find / -name "fileName" | find / -name "fileName" | ||
− | Using find to recursively unzip all items in a directory structure to the current directory. | + | Using find to recursively unzip all items in a directory structure called zippedDir to the current directory. |
find /zippedDir -name "*.zip" -exec unzip {} \; | find /zippedDir -name "*.zip" -exec unzip {} \; | ||
− | ==Copy a file== | + | ===Copy a file=== |
cp origin /destination/file | cp origin /destination/file | ||
Line 49: | Line 52: | ||
==Network== | ==Network== | ||
+ | Download the Latest Version of Retain | ||
+ | wget "http://download.gwava.com/download.php?product=Retain&version=current" | ||
+ | |||
Find the IP address of the server | Find the IP address of the server | ||
ifconfig | ifconfig |
Revision as of 16:45, 23 November 2015
Useful Linux Commands
You can use man [command]
to get information about a command, but that is more programmer-centric. You are generally better off going to a search engine and searching for [command] examples
.
Contents |
Disk Commands
Returns a quick overview of what disks are mounted and how full they are in human readable formatting.
df -h
Directory Commands
Directory details
Returns a total size of the directories under where this command was run and sorts by size. Warning: May take a long time.
du -hsx * | sort -rh | head -10
File List
Return a list of files in a directory. This always works (shows file size in bytes)
ls -s
This is a SLES alias of the above
l
File size in human-readable values (K,M,G)
l -h
Sorted by size ascending human-readable
l -Srh
Sorted by time ascending human-readable
l -trh
Create a directory
md [directory name] mkdir [directory name]
File Commands
Find a file
find / -name "fileName"
Using find to recursively unzip all items in a directory structure called zippedDir to the current directory.
find /zippedDir -name "*.zip" -exec unzip {} \;
Copy a file
cp origin /destination/file
To copy particular files recursively
cp -r *.txt /destination
To copy to the current directory
cp /software/origin.file .
Network
Download the Latest Version of Retain
wget "http://download.gwava.com/download.php?product=Retain&version=current"
Find the IP address of the server
ifconfig
look up mx records
host -t MX [domain.com]
Determine hosts
cat /etc/resolv.conf
DNS
nslookup "Enter" server "Enter"
Trace the route to a server
traceroute [domain.com]