1 Some useful UNIX Commands 12th January 2010, 8:36 pm
C0D3R
MITR Master
Some useful UNIX Commands for newbies to get a start in UNIX
Part 1: Working with files and rights
cp <source> <dest> --- Copies the source file to dest
mv <source> <dest> --- Moves source to dest (if a directory,
else it renames source to dest)
cd <directory> --- Changes the current directory
pwd --- Shows the current directory
mkdir <directory> --- Creates a directory
rm <directory> --- Deletes a directory, if empty
rm -R <directory> --- Deletes a whole directory with subdirectories
(like DELTREE <directory>)
rm <file> --- Deletes a file
chmod userMODErights --- Changes the mode of a file
user=(u)ser (current user)
(g)roup (group of current user)
(o)ther (all, except user&group)
(a)ll (all )
MODE=(+) add rights
(-) remove rights
rights=(r)eadable
(w)ritable
e(x)ecutable
df --- Shows free disk space
find / -name "<file>" --- Searches the whole tree for a file (>
DIR <FILE> /S)
whereis <file> --- Searches the path for a file
grep -l "<Text>" <files> --- Shows all files, which contain the
given <Text>
cmp <file1> <file2> --- Compares <file1> with <file2>
diff <file1> <file2> --- Compares <file1> with <file2> and show
the difference
between them
head <file> --- Shows the first 10 lines of the file
tail <file> --- Shows the last 10 lines of the file
nl <file> --- Shows the lines of the file numbered
sort <file> --- Shows the lines of the file in sorted order
strings <file> --- Shows only the readable strings of a
file
wc <file> --- Shows lines, words, bytes of a file
file <file> --- Gives information about a file
touch <file> -a -m -c -t MMDDhhmmCCYY --- Changes the timestamp of a file
-a (Change Access-time)
-m (Change Modification-time)
-c (Don't create files, that don't exist)
pico [file] --- An easy to use ASCII-Editor.
script <file> --- Copies the text, that is entered
between this command
and the "exit"-command in <file>
lpr <file> --- Prints a file
lprm <file> --- Removes file from Printing Queue
sudo <file> --- Executes file with SuperUser-Rights (Only
when
user is in SUID-List, else it will be
reported
to root)
Part 1: Working with files and rights
cp <source> <dest> --- Copies the source file to dest
mv <source> <dest> --- Moves source to dest (if a directory,
else it renames source to dest)
cd <directory> --- Changes the current directory
pwd --- Shows the current directory
mkdir <directory> --- Creates a directory
rm <directory> --- Deletes a directory, if empty
rm -R <directory> --- Deletes a whole directory with subdirectories
(like DELTREE <directory>)
rm <file> --- Deletes a file
chmod userMODErights --- Changes the mode of a file
user=(u)ser (current user)
(g)roup (group of current user)
(o)ther (all, except user&group)
(a)ll (all )
MODE=(+) add rights
(-) remove rights
rights=(r)eadable
(w)ritable
e(x)ecutable
df --- Shows free disk space
find / -name "<file>" --- Searches the whole tree for a file (>
DIR <FILE> /S)
whereis <file> --- Searches the path for a file
grep -l "<Text>" <files> --- Shows all files, which contain the
given <Text>
cmp <file1> <file2> --- Compares <file1> with <file2>
diff <file1> <file2> --- Compares <file1> with <file2> and show
the difference
between them
head <file> --- Shows the first 10 lines of the file
tail <file> --- Shows the last 10 lines of the file
nl <file> --- Shows the lines of the file numbered
sort <file> --- Shows the lines of the file in sorted order
strings <file> --- Shows only the readable strings of a
file
wc <file> --- Shows lines, words, bytes of a file
file <file> --- Gives information about a file
touch <file> -a -m -c -t MMDDhhmmCCYY --- Changes the timestamp of a file
-a (Change Access-time)
-m (Change Modification-time)
-c (Don't create files, that don't exist)
pico [file] --- An easy to use ASCII-Editor.
script <file> --- Copies the text, that is entered
between this command
and the "exit"-command in <file>
lpr <file> --- Prints a file
lprm <file> --- Removes file from Printing Queue
sudo <file> --- Executes file with SuperUser-Rights (Only
when
user is in SUID-List, else it will be
reported
to root)