Wednesday, April 30, 2008

Common linux commands -- Slackzen

Common Linux Commands
less

cat

more

vi

cd

ls

ln {oldfile} {newfile} (create a file link)

mv [options] source dest (Remove and rename files or directories)

-b (backup files that are about to be overwritten)

-i (interactive mode)

mkdir [directoryName]

rmdir [directoryName]

rm -rf [directoryName] //force delete recursively without prompting

tail -1000f access_log //use Ctrl+C to break it out.

touch

cp [options] source dest

-b, -i (same as above)

-p (preserve the original file's ownership, group, permissions and timestamp (the meta info)

chmod{u|g|o|a} {+|-} {r|w|x} {filename}

chown

find managmentconsole/ -name "MCExcep*"

find . -name CVS -exec ls Tag {} \;

grep [options] pattern filenames

-i (case sensitive)

-n (show the line# along with the matched line)

-v (invert match, find all lines that do NOT match)

-w (match entire words)

grep -R "a string" /etc/*

pwd //Display the present working directory

which //Display a program's executable path

whoami

whereis //Locates binaries and manual pages for the ls command.

---------------------------------------------------------

System Command

---------------------------------------------------------

date //check timestamp

df //Available free disk space

ps

pstree

kill

man (View manual pages)

mail (Read your email)

mount

umount

printtool (Use to set up printer)

top (memory usage profile)

su/changeme (do things as superuser), exit (back to original user)

passwd

nohup ./start.sh & //start a program remotely in the background


---------------------------------------------------------

Establish Cron job

---------------------------------------------------------

crontab -e Edit your crontab file, or create one if it doesn't already exist.

crontab -l Display your crontab file.

crontab -r Remove your crontab file.

crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.)

* * * * * command to be executed

- - - - -

| | | | |

| | | | +----- day of week (0 - 6) (Sunday=0)

| | | +------- month (1 - 12)

| | +--------- day of month (1 - 31)

| +----------- hour (0 - 23)

+------------- min (0 - 59)


------------------------------------------------------

Process handling

------------------------------------------------------

CTRL+Z (suspend the job -- stop running, instead of '&' that job is still running in background)

>> [1]+ Stopped ls -R | more (+ mean the lastest job that got suspended, and you can suspend >1)

fg (it will bring back the latest job got suspended)

fg # (selectively bring back a job)

fg %find (bring back a process that start with "find" string - find command process)

fg %?usr (bring back a process that contains 'usr' in its command path)

bg %[number] (send the job 1 to background as &)

bg %[string]

kill %[number]

kill %[string]

jobs (to list out all the suspended jobs)

[1] Stopped ls -R /usr >> output

[2]+ Stopped find / -print > output.find

[3] Stopped ls -R /var >> output

[4]- Stopped ls -R >> output

[5] Running ls -R /var >> output &
Job 2 now has + sign following it (latest job that suspended)

Job 4 has the minus sign (2nd last job suspended)

Job 5 is running in the background still (notice & sign)


------------------------------------------------------

Compression/ Decompression of files

------------------------------------------------------

Compressed files use less disk space and download faster than large,
uncompressed files. You can compress Linux files with the open-source
compression tool Gzip or with Zip (for file exchange with non-Linux user), which is recognized by most operating systems. You use Tar to achive files into single tar but it doesn’t do compression automatically.
gzip filename.ext (compress a file and saved as filename.ext.gz)

gzip filename.gz file1 file2 mydir/ (compress to a gz file)

gunzip filename.ext.gz (expand the compressed file)

gzip -d xxx.tar.gz (Uncompress the .gz file)

zip -r filename.zip files (compress a file with zip)

unzip filename.zip (expand the compressed zip file)

unzip -l xxx.zip (list all the file out)

zip -d br_MgmtConsole3Dev.zip \*\target\* (delete everything with target in the path inside the zip)

tar -cvf xxx.tar [files or directories] (create tar)

tar -czvf xxx.tgz mydir/ (create tgz = tar.gz)

tar -xvf xxx.tar (untar)

tar -xzvf xxx.tgz (untar tgz)

tar -tvf xxx.tar (to list the contents of a tar file)

jar cf abc.jar com com2 ... (jar the directory recursively with space separated to the abc.jar)

jar xf abc.jar (Extract)

jar -tvf xxx.war (examine what is inside it)

jar cf cocoon-2.1.5.1.war webapp (create a war file from the webapp directory)

jar tvf weblogic.jar |grep bcel (do the search on the output)


------------------------------------------------------

Networking

------------------------------------------------------

Here is good linux networking guide for your reference.

Host file location: /etc/hostsifconfig (check your box's IP address)

ping (send ICMP ECHO_REQUEST packet to the specific host. If the host is alive, an ICMP packet will be sent back)

traceroute www.justproposed.com (It displays each host that a packet travels through)

host www.justproposed.com (return IP of JP)

nslookup 64.102.102.32 (return DNS name of the IP)

netstat (port scan in the localbox)

finger

telnet <hostname> <port> (quick test to see if a remote service is up or not)

dig @192.168.1.254 www.slackware.com mx (“@192.168.1.254” specifies the
dns server to use. “www.slackware.com” is the domain name I am
performing a lookup on, and “mx” is the type of lookup I am performing.
The above query tells me that e-mail to www.slackware.com will instead
be sent to mail.slackware.com for delivery.)

ssh

sftp hostname (then you can do "put filename")

scp filename remote_host:directory (Copy a file from current directory to remote directory /home/honr). eg. scp filename1 honr@appden11.xyz.net:/home/honr

scp honr@appden11.xzy.net:/home/honr/filename . (Copy a file from remote directory to my current directory)

wget <url> (download a file from the url - http or ftp)

wget –recursive <url> (download the whole site)

ftp <url> (connect to ftp server and you can issue command once connected)

curl -I www.google.com/”>http://www.google.com (Get the HTTP Header)

Tuesday, April 29, 2008

Installing Slackware on encrypted volumes

from : http://slackware.osuosl.org/slackware-12.0/README_CRYPT.TXT

The Hacker : Gary McKinnon

In 2002, Gary McKinnon was arrested by the UK's national high-tech
crime unit, after hacking into NASA, and the US military. He says he
... all » spent two years looking for photographic evidence of alien
spacecraft and advanced power technology. America now wants him on
trial, and if tried there he could face 60 years behind bars. Gary's
been banned from using the Internet. We asked for his side of the story
ahead of his extradition hearing on Wednesday...

http://opensc.ning.com/video/video/show?id=610837:Video:1682

gpgdir

gpgdir is a perl script that uses the CPAN GnuPG::Interface module to encrypt
and decrypt directories using a gpg key specified in ~/.gpgdirrc .

Nice tool to have...

visit: http://cipherdyne.org/gpgdir/

Tuesday, April 08, 2008

Zenwalk 5.0 : The Best of The Best

So far, I have tried so many distros like : Fedora, Ubuntu, Mepis, Damn Small, Mandriva/Mandrake,
Wolvix, etc....but only Slackware and Zenwalk have what I wanted. At this moment, I decided to keep Zenwalk because it is small, compact, super fast((probrably the fastest distro)) and
of course since it has a Slackware foundation it is rock-solid and super stable. I can do pretty much whatever I want and will do it for me. Hackers should be in heavens with this distro.

I erased Ubuntu since it was getting fat and installed Zenwalk...I am keeping this one for good.

-2501