Difference between revisions of "Linux Commands"

From GWAVA Technologies Training
Jump to: navigation, search
Line 37: Line 37:
  
 
==File Commands==
 
==File Commands==
 +
Show the contents of a file
 +
cat "filename"
 +
 +
Pipe through more to display a screen full of text at a time (space for next page, enter for next line, ctrl-c to break out)
 +
cat "filename" | more
 +
 +
Pipe through less to display file in less.
 +
cat "filename" | less
  
 
===Find a file===
 
===Find a file===
 
  find / -name "fileName"
 
  find / -name "fileName"
  
Using find to recursively unzip all items in a directory structure called zippedDir to the current directory.
+
Find all files with the string "log" as part of the filename.
 +
find . | grep log
 +
 
 +
Find and 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 {} \;
 +
 +
Find files in current directory older than 7 days and delete them.
 +
find . -mtime +7 -exec rm {} \;
  
 
===Copy a file===
 
===Copy a file===
Line 72: Line 86:
 
Trace the route to a server
 
Trace the route to a server
 
  traceroute [domain.com]
 
  traceroute [domain.com]
 +
 +
Show the system name
 +
hostname
 +
 +
Secure connect to another system
 +
ssh [hostname or ip address]
 +
exit to leave ssh shell
 +
==System Commands==
 +
Display an overview of the system resources
 +
top
 +
 +
Display memory usage
 +
free -m

Revision as of 17:05, 23 November 2015

Useful Linux Commands

You can use man [command] to get information about a command, but that is more programmer oriented. 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 an estimate of file space usage, in human readable format (k,M,G). Warning: May take a long time.

du -h

Returns a total size of the directories under where this command was run and sorts by size.

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

Show the contents of a file

cat "filename"

Pipe through more to display a screen full of text at a time (space for next page, enter for next line, ctrl-c to break out)

cat "filename" | more

Pipe through less to display file in less.

cat "filename" | less

Find a file

find / -name "fileName"

Find all files with the string "log" as part of the filename.

find . | grep log

Find and recursively unzip all items in a directory structure called zippedDir to the current directory.

find /zippedDir -name "*.zip" -exec unzip {} \;

Find files in current directory older than 7 days and delete them.

find . -mtime +7 -exec rm {} \;

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]

Show the system name

hostname

Secure connect to another system

ssh [hostname or ip address]
exit to leave ssh shell

System Commands

Display an overview of the system resources

top

Display memory usage

free -m
Personal tools
Namespaces

Variants
Actions
Home
Exchange
GroupWise
JAVA
Linux
MTK
Retain
GW Monitoring and Reporting (Redline)
GW Disaster Recovery (Reload)
GW Forensics (Reveal)
GWAVA
Secure Messaging Gateway
GW Mailbox Management (Vertigo)
Windows
Other
User Experience
Toolbox
Languages
Toolbox