Linux Commands: Examples of how to use some common linux commands
wall "message" -- send a message
to everybody's terminal (broadcasting a message to all)
dd if=ntbootdisk.img of=/dev/fd0 bs=512 (this command will take
the file "ntbootdisk.img" and write its entire contents
to a /dev/fd0)
dd if=/dev/hda1 of=/mnt/harddrive (this will take the drive
/dev/hda1 and copy it to the image /mnt/harddrive)
kill or killall -9 process (will kill the process)
find / -name 'tacos' (will start from root / and search for
file named tacos)
df -h (check disk space on all mounted harddrives)
fdisk / cfdisk (create and view partition
tables)
date --set='Sat Feb 10 02:59 PST 2001' (setting time on linux
machine)
mount -t smbfs -o username=user,passwd=password //server/share
/mnt (this command will mount a Windows share)
rm -rf (remove directory and files stored in directory)
elm -f mailbox
mutt -f mailbox
uname -ra (show current kernel version)
sendmail -bt -d0 (info on sendmail version
and more)
sendmail -bi (run this commands to refresh the /etc/mail/aliases
and
/etc/mail/majordomo.aliases files)
sendmail -q (this command will process all files in the sendmail
queue, which is usually located under /var/spool/mqueue)
whereis, locate, and find are all search commands
fg (fore ground) when running a task and using
crtl-z to exit that task
run fg to move between applications.
jobs - list all jobs running in foreground
ps -aux ( show all processes that are being
ran on this system)
ps -aux | grep %file% (search for a process that is running)
## restarting sendmail hashes files as needed.
(even aliases)
makemap hash mailertable < mailertable
(run in the /etc/mail directory
this will refresh the .db table)
who or w - show all users logged in
last -n - show the last user or users that
logged onto your system. You can also specify the "n"
command to specify the number of lines you'd like to view.
talk - used to talk with other users on the
system
chown - change the current ownership of a
file or folder (using the "-r" parameter will change
ownership of a file/directory recursively.)
chmod - change the file attributes on a system
chgrp - change group ownership of a file or folder
mkdir - make a directory
rm - remove a file (use the "-rf" paramter to force
a recursive removal of files and directories. Be very careful
when using these paramters, or you'll nuke your system entirely.)
rmdir - remove a directory
ln -sf creates a symbolic link to a folder
or file (example: "ln -sf /www/html www" will create
a shortcut to /www/html called "www", also might
want to check out hardlinks/softlinks)
e2fsck /dev/hda - use to fix problems with ext2 volumes (remember
to umount the device you're attempting to check. If the device
is root, simply reboot in "single" mode and run
the e2fsck /dev/hda/sdaxx command)
fdisk - use to partition a harddrive
cfdisk - view and edit partitions running in bash shell.
mkfs.ext2 - use after creating a partition with fdisk
# ifconfig: alias and setup gateway/netmask
! /sbin/ifconfig eth0:1 10.0.0.35
! route add -net 190.6.9.0 netmask 255.255.255.0 gw 1.2.3.33
eth0:1
! route add default gw 1.2.3.33 metric 1 eth1
# view all packets from host 10.0.0.35 and not port 22 (SSH)
tcpdump -i eth0 host 10.0.0.35 and not port 22
Applying a patch (Most of the time you will
be supplied with instuctions)
1) Copy file to patch location mv patch.x.gz /web/src/main
2) Change to directory where patch is run command "cat
patch.x.gz | patch -d0" or "gunzip patch.tar | patch
-d0"
gunzip = the type of compression that was applied with the
patch (cat would mean 0).
| = execute command while displaying output
patch = linux program that is used to apply patches
-d0 = -d dir or --directory=dir Change to the directory dir
immediately, before doing anything else.
3) Finally you will need to recompile the program.
Another example of a patch being applied to an application:
bzip2 -dc patchname.bz2 | patch
howto
link: http://www.linuxhq.com/patch-howto.html
---------------------------------------------------------------------------
|