Search Commands |
|
grep x file |
searches for x in file |
grep -i |
case insens-itive search |
grep -r |
recursive search |
grep -v |
inverted search |
grep -o |
shows only matched part of the file |
find /dir/ -name aaa
* |
finds files starting with aaa in dir |
find /dir/ -user Tom |
finds files owned by Tom in dir |
find /dir/ -mmin
10 |
finds files modifed less than 10 minutes
ago in dir |
find /home -size +500M |
finds files larger than 500MB in /xyz |
find [/folder/location] -name [x] |
finds file names starting with character x |
whereis aaa |
ocates the binary, source, and manual page
of aaa |
locate abc |
finds the location of abc quickly |
|
|
Process Management Commands |
|
ps |
displays currently running processes |
ps PID |
gives the status of a particular process |
pidof |
gives the process ID of a process |
ps -ef |
displays all running processes on the system |
ps -ef | grep xyz |
displays process information for xyz |
top |
displays and manages the top processes |
htop |
interactive process viewer (top alternative) |
kill pid |
kills process with process ID of pid |
pkill xyz |
kills process with name xyz |
killall abc |
kills all processes named abc |
program & |
starts program in the background |
bg |
lists and resumes stopped jobs in the background |
fg |
brings the most recent background job to
foreground. |
fg x |
brings job x to the foreground |
nice |
starts a process with a given priority |
renice |
changes priority of an already running process |
pstree |
displays processes in a tree-like diagram |
pmap |
displays a memory usage map of processes |
lsof |
lists files opened by running processes |
Search Commands |
|
command -h / command –help |
to review all available options of the “command” |
info command |
to find info documents about the “command” |
whatis command |
displays a single line description about the”command” |
$ man UNIXCOMMAND |
to view detailed man page of the “command” |
apropos |
used to search man pages for available commands on a specific |
|
|
File Transfer Commands |
|
scp file.txt server:/tmp |
secure copy file.txt to the /tmp folder on server |
scp server:/var/www/*.html /tmp |
secure copy *.html files in /var/www/ directory on server to |
scp -r server:/var/www /tmp |
secure copy all files and directories recursively from server to the |
rsync -a /home /backups/ |
synchronize /home to /backups/ |
rsync -avz /home server:/backups/ |
Synchronize files/directories between the local and remote |
|
|
Disk Usage Commands |
|
df |
shows free hard disk space on the system |
df -h |
shows free and used space on mounted filesystems |
df -i |
shows free and used inodes on mounted filesystems |
fdisk -l |
shows free and used inodes on mounted filesystems |
du -sh |
shows total disk usage off the current directory |
du -ah |
shows disk usage for all files and directories in readable format |
free |
shows free RAM on the system |
free -h |
shows free and used memory |
findmnt |
shows target mount point for all filesystem |
mount /xyz /abc |
mounts a device in /xyz to /abc |
|
|
Compress and Decompress Commands |
|
gzip abc |
compresses abc file using gzip. |
bzip2 abc |
compresses abc file using bzip2 |
tar -czvf archive.tar.gz /home/temp2/ |
compresses a full directory with all subdirectories |
gzip -d xyz.gz |
extracts xyz.gz with gzip utility |
gunzip xyz.gz |
extracts xyz.gz with gzip utility |
bzip2 -d file.php.bz2 |
extracts xyz.gz with bzip2 utility |
bunzip2 file.php.bz2 |
extracts xyz.gz with bzip2 utility |
unzip xyz.zip |
extracts xyz.zip with zip utility |
gunzip -c output.txt.gz |
to view the contents of both files without extracting |
tar cf archive.tar directory |
creates tar named archive.tar containing directory |
tar xf archive.tar |
extracts the contents from archive.tar |
tar czf archive.tar.gz directory |
creates a gzip compressed tar file name archive.tar.gz |
tar xzf archive.tar.gz |
extracts a gzip compressed tar file |
tar cjf archive.tar.bz2 directory |
creates a tar file with bzip2 compression |
tar xjf archive.tar.bz2 |
extracts a bzip2 compressed tar file |
No comments:
Post a Comment