Thursday, October 15, 2009

Unix basic commands

Part 1: Working with files and rights-------------------------------------
cp
--- Copies the source file to dest
mv --- Moves source to dest (if a directory,
else it renames source to dest)
cd --- Changes the current directory
pwd --- Shows the current directory
mkdir --- Creates a directory
rm --- Deletes a directory, if empty
rm -R --- Deletes a whole directory with subdirectories
(like DELTREE )
rm --- 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 "" --- Searches the whole tree for a file (>
DIR /S)
whereis --- Searches the path for a file
grep -l "" --- Shows all files, which contain the
given
cmp --- Compares with
diff --- Compares with and show
the difference
between them
head --- Shows the first 10 lines of the file
tail --- Shows the last 10 lines of the file
nl --- Shows the lines of the file numbered
sort --- Shows the lines of the file in sorted order
strings --- Shows only the readable strings of a
file
wc --- Shows lines, words, bytes of a file
file --- Gives information about a file
touch -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 --- Copies the text, that is entered
between this command
and the "exit"-command in
lpr --- Prints a file
lprm --- Removes file from Printing Queue
sudo --- Executes file with SuperUser-Rights (Only
when
user is in SUID-List, else it will be
reported
to root)
Part 2: Working with archives-----------------------------
tar -cvf --- Creates and stores
the files (uncompressed)
in this archive
tar -xpvf --- Extracts the files from the
archive
tar -tf | less --- Shows the contents of an archive
gzip --- Compresses the
gzip can only compress one file, so you'll
have to
archive the files with tar and then gzip
them.
This will give you a file.tar.gz
tar -zxf --- Decompresses and Extracts the files
tar -M -cvf /dev/fd0h1440 --- Creates a Multi-Volume-Archive (for
floppy discs)
tar -M -xpvf /dev/fd0h1440 --- Extracts a Multi-Volume-Archive
Part 3: Working with filesystems
--------------------------------
Formatting a Floppy Disc.
Step 1 -- Format the disc
fdformat /dev/fd0H1440
Step 2 -- Create a Filesystem on the disc
mkfs -t -c /dev/fd0H1440
stands for the filesystem. This can be ext2/minix/msdos (for floppys
normal is minix)
To use a floppy disc or a cd-rom, you'll have to mount them before.
mount
Floppy: mount /dev/fd0 /floppy (you can use any directory, but floppy
would be normal,
I think.)
CD-ROM: mount /dev/hdc /cdrom
Part 4: Working in Networks---------------------------
Connect to a remote machine, and execute programs on it.
telnet remote.host.org --- Connect to a remote machine
You can then execute programs on the remote
machine in the
terminal.
uname -a --- Gives information about the current system
w --- Shows who is currently logged in and what he
is running
finger --- Shows who is logged in.
With "finger " you can get more
information about
specific users
passwd --- Change User Password
write [] --- Write a message to .
If is logged on more than one
terminal, you can
specify it in . To answer you, the
must
also start "write"
chsh --- Changes the login shell
Part 5: Programming-------------------
cc -o --- compiles the Source file into Output
file
gcc -o --- same
gcc -o -l --- links the library to the file
The C functions are declared in manual 3 ==> man 3
Part 6: Doing jobs in the background
------------------------------------
If you add an & at the end of a command, it will start in the background.
Exmpl: fdformat /dev/fd0h1440 &
ps -a --- Shows all current processes
kill --- End process
kill -9 --- Forces the process to end
You can stop the processes on two ways and make them to jobs.
CTRL-C --- Stop process
CTRL-Z --- Stop process temporarily
bg --- Brings a job into background
fg --- Brings a job into foreground
kill <%job> --- End job
jobs --- Shows all current jobs
Part 7: Escape Sequences
------------------------
\a Bell
\b backspace
\f feed
\n linefeed
\r carriage return
\t tab horizontal
\v tab vertical
Ending
------
This text should just provide some basic skills, so that you can start using
UN*X. I know it isn't
declared very much, but i like short tables, being able to lookup a certain
command. If you need to
know more specific switches you can always consult the manuals with: man
.


Print this post

No comments: