Wednesday, May 13, 2009

Several Linux commands

  1. Use 'cd –' to toggle between the last two directories:
  2. # cd /tmp/data/calibration
    # cd /root/usr/

    # cd -
    # pwd
    /tmp/data/calibration

    # cd -
    # pwd
    cd /root/usr/

  3. history 10

    use Control-R to search the history (same as Emacs C-r, C-s). Press Left/Right arrow key to edit the command before executing.
    C-p to display previous command (!! enter)
    history –c, clear all
    command, this command will not show in history [this line updated on 10/23/09]

  4. tar [options] [tar-archive-name] [other-file-name]:

    [option c] stands for create an archive
    [option v] stands for verbose mode, displays additional info while executing the command
    [option f] indicates the archive file name mentioned in the command
    [option t] display all the files from the tar archive
    [option z] when dealing with tar.gz compressed file
    [option j] when dealing with tar.bz2 compressed file

  5. tar cvf /tmp/myfile.tar /home/peter
    tar tvf /tmp/myfile.tar
    tar xvf /tmp/myfile.tar

    tar cvfz /tmp/myfile.tar /home/peter
    tar xvfz /tmp/myfile.tar

  6. in ~/.bash_profile, separating them with :,

  7. export CDPATH=/etc
    export CDPATH=/var:/home:~:/home

  8. list the files in the ascending/descending order of file size

  9. ls -al | sort +4n
    ls -al | sort +4nr

No comments:

Post a Comment