Sunday, July 24, 2011
9:31 AM

GNU/Linux Most Wanted Command 2

The next series of GNU/Linux Most Wanted Command

Listing files / directory

  • ls : list all file(s) / directory
  • ls -l : list / display with a long listing atributes
  • ls -a : display all file(s) and directory including hidden files(s) / directory ( starting with . )
  • ls -S : display with the biggest size first
  • ls -ltr : display longlist with most recent at last
  • ls -r : display with a reverse sort order
Displaying text file content

cat text-file

i.e

cat readme.txt


File access right

Add write permissions to the current user :

  • chmod u+w file-name

Add read permission to users in the file group

  • chmod g+r file-name

Add read + write permissions to all users :

  • chmod a+rw file-name

Make the whole directory and its contents accessible by all users :

  • chmod -R a+rx directory-name
Compressing

gzip file-name (.gz format)
bzip file-name (.bz2 format)
lzma file-name (.lzma format)

Uncompress

gunzip file.gz
bunzip2 file.bz2
unzlma file.lzma

Tape Archive

Create a compressed archive

tar zcvf archive.tar.gz dir
tar jcvf archive.tar.bz2 dir
tar ­­lzma ­cvf archive.tar.lzma

Test (list) a compressed archive:

tar ztvf archive.tar.gz
tar jtvf archive.tar.bz2
tar ­­lzma ­tvf archive.tar.lzma

Extract the contents of a compressed archive:

tar zxvf archive.tar.gz
tar jxvf archive.tar.bz2
tar ­­lzma ­xvf archive.tar.lzma

tar options:

c: create
t: test
x: extract
j: on the fly bzip2 (un)compression
z: on the fly gzip (un)compression

Handling zip archives

zip ­r archive.zip (create)
unzip ­t archive.zip (test / list)
unzip archive.zip (extract)

Basic Administration

Reboot macine (now)

sudo reboot

Reboot the machine in times minutes :

i.e

Reboot machine in next 5 minutes

sudo shutdown -r +5

Shutdown machine

sudo halt


0 comments:

Post a Comment