Sunday, November 29, 2009

Linux command

* Listing files/folder
ls -lht
-l: long format
-h: human readable size (ex: 2k, 2M,..)
-t: sort by time (default = sort by name)
* Count number of line in file
wl -l filename
* Get last 100 line of a file and numbering
tail -100 source | nl > dest
* Remove whole directory and all files inside
rm -r folder_name
-r: recursive
* Backup a folder
tar -cvf file.tar folder_name
* Extract a file
tar -xvf file.tar
* Disk use:
du - sh
-s: only total sum
-h: size human format
du | sort -n (unix)
du | sort -g (fedora)
* Install package
sudo apt-get install vim-runtime
* Check disk space
df -h
* Check memory
prstat -a
* Find file
find / -name filepattern
locate filepattern
* Mound a pen drive
mount /dev/sda1 /mnt/usbdisk
* Change mode
chmod ugo+rwx directory1
* Find text in files
find . -type f -exec grep "pattern" {} \;
* Make a pdf of a manual page
man -t man |ps2pdf - > man.pdf
* Go to previous directory
cd -

No comments:

Post a Comment