Thursday, April 5, 2007

Linux command cheat sheet

Linux Cheat Sheet

Getting Around in the File System
pwd
Path of working directory - tells you what directory you are in

ls
List - Lists the files in the current directory

ls -l

Lists the files and their attributes

cd

change directory - Change to the directory specified

Dealing with Files

cp

copy - Make a copy of a file

cp -R

Make a copy of a directory

mv

move - Move or rename a file

rm

remove - Delete a file

more

Page through a file.

grep

Search a file for a keyword

vi

Edit a file. (See Ruling WebGUI's vi Cheat sheet for details>

chmod

change mode - Change the mode or permissions on a file.
Mode = ogw or owner, group, world permissions. example: 755
0=nothing
4=read
5=read / execute
6=read / write
7=read / write / execute

chown

change owner - Change the owner of a file

Dealing with Environment Variables

export =

Set and environment variable in teh current shell.

set

Show all of the current envireonment variables that have been exported

unset

Delete an environment variable

Power Users

df -k

Determine how full the partitions on the local hard disks are.

du -ks

Determine the disk usage of a given directory and all sub directories

find -name

Locate a file on the file system.

ps -ef

Get a look at the processes running on the machine

top

Take a look at the memory and CPU usage as well as the top processes on the machine

man

Get help for a given command

diff

Report the differences between two files.

gzip

Compress a file.

gunzip

Decompress a file.

tail

Look at the end of a file.

tar cf ./*

Tar all the files in this directory into a tar-ball in the lower directory

tar xvf

De-tar the contents of a tar-ball

Perl Specific

perl -w

Execute a Perl Script with warnings.

perl -c

Get compilation errors for a Perl script

perldoc ::

Get help for a Perl function in a given module.

perldoc perlfunc

Get help on basic Perl functions.

perldoc perlpod

Get help on Perl (POD = Plain Old Documentation) documentation

Java Specific

java

Run a compiled class

java -client

Run a compiled class where the JVM is optimized as a client

java -server

Run compiled class where the JVM is optimized as a server

javac

Compile a source file

No comments: