Geeks With Blogs
Tim Huffam Dotting the I and crossing the T of I.T.

For those of you, like me with a memory like a seive.. here's a quick 101 on linux/unix commands:

 

Help/Manual (to get help on a command or shell):

man eg:

man cp

The following will show details of how to work within a shell, ie syntax for pipes, scripting etc

man sh

man bash

Once within man:

= scroll down 1 line

= scroll down 1 page

Q = quit.

Display contents of a file or output stream:

more

Once within man:

= scroll down 1 line

= scroll down 1 page

Q = quit.

List files in a dir:

ls (file/dir names only) eg:

ls

ls *.txt

ls -l (full listing of file/dir details)

ls -l

ls -l *.txt

Redirect output stream (of a command) to a file:

> (overwrite) eg:

ls > files.txt

>> (append) eg:

ls >> files.txt

Pipe output string (of a command) to another command:

| eg:

ls | more

Change directory:

cd

Show current directory:

pwd

Copy:

cp

Move & Rename:

mv

Delete/Remove file:

rm

Delete/Remove directory:

rm -r

Filter data:

grep '' eg:

ls -l | grep 'myfile'

The search can be inverted with -v eg:

ls -l |grep -v 'myfile'

Count occurances of something:

grep -c eg?:

ls -l |grep -c 'myfile'

or by using wc eg:

ls -l | wc -l

Find a file containing:

find . |xargs grep -il 'text to search for'

Tar - to create a tar file:

tar -cvfz (Create,Verbose,File,gZip) eg

tar cvfz upgrade_datasynapse.tyar.gz datasynapse

z (gzip) is optional - if you want to compress/zip the tar

UnTar - to extract a tar file:

tar -xvfz (eXtract,Verbose,File,gZip) eg

tar xvfz upgrade_datasynapse.tyar.gz

z (gzip) is optional - if you want to uncompress/unzip the tar

List contents of aTar file:

tar -tvfz (lisT,Verbose,File,gZip) eg

tar tvfz upgrade_datasynapse.tyar.gz

z (gzip) is optional - if the tar file is compressed/zipped

Show processes:

ps -ef

Show process tree:

pstree -ahp

Show resource usage (cpu, memory, time, etc):

top

Note that top shows a line for each thread.  To make it show processes only (one line per process) type Shift-H when top is running.

Edit a file:

if you're a masocist use:

vi

or:

use a GUI (KDE/gnome) text editor

or:

Setup Samba (file system sharing) on your linux box and use a Windows editor

or:

Setup an ftp server on your linux box then use a cool windows editor called EditPlus (www.editplus.com) as it has FTP support built into it so it can Open/Save files to/from an FTP server.

Show disk usage:

df -k

Estimate disk usage:

du -k | sort -n

Print files:

lp

 

 

Posted on Friday, November 25, 2005 9:23 AM OS/Networking/Misc Apps , Linux | Back to top


Comments on this post: Linux/unix commands cheatsheet

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Tim Huffam | Powered by: GeeksWithBlogs.net