linux journey

linux journey

command line

shell

  • let’s start with a siple command, echo. The command just prints out the arguments to the display.
    1
    echo hello,world!

    pwd (print working directory)

    1
    pwd

    cd (change directory)

    1
    2
    cd /etc/test
    cd test2
  • . ( current directory)
  • .. (parent directory)
  • ~ (home directory)
  • - (previous directory)

ls (list directories)

1
2
3
4
5
6
7
8
ls 
ls /home
ls -a show all of the files include the files which are hidden.
ls -l l means long, this command will show the files with their detile.
ls -la show all the files with their detile.
ls -R recursively list directory contents.
ls -r reverse order while sorting.
ls -t sort by modification time, newest first.

touch (create a filw)

  • touch allows you to create new empty files.
    1
    touch myfile
  • touch is also used to change timestamps on existing files and directories.
    1
    2
    touch myfile
    touch mydirectory

file (show the type of the file’s contents)

1
file myfile

cat (show the content of files)

1
cat file1 file2

less (show less of a file)

  • if you are viewing text files larger than a simple output.(which means it is too big to view on your screen.) you can use less to open it, that can make it easy to view the file.
    1
    2
    3
    wget linuxqq_2.0.0-b2-1089_x86_64.sh
    mv linuxqq_2.0.0-b2-1089_x86_64.sh qq
    less qq
  • the text is displayed in a paged manner, so you can navigate through a text file page by page.

    q quit out of less and back to your shell
    Page up, Page down, up and down Navigate.
    g move to the beginning of the text file
    G move to the end of the file
    h help
    /search search the content behind /

1
2
less qq
/qq

history

1
2
3
history   show commands you have typed
ctrl-R
clear clear the screen

cp (copy)

1
2
3
4
cp myfile /home/files
cp *.jpg /home/jpgs
cp -r directoryone/ /home/document copy the directory
cp -i my file /home/files prompt you before overwriting a same-name-file.

mv (move)

  • rename file or directory
    1
    2
    mv a b
    mv directory1 directory2
  • move files and directories to somewhere
    1
    mv a b directory1 directory2 /home
  • wanna a prompt
    1
    mv -i directory1 directory2
  • make a backup of the file which is going to be overwritten.
    1
    2
    mv b a
    the previous file a will be back up and renamed as ~a

    mkdir (make a directory)

    1
    mkdir one two
  • wanna to create subdirectories?
    1
    mkdir -p one/one two/tow

    rm (remove)

  • delete a file. the file being deleted will not been pushing into a trash can, so be careful about rm.
    1
    rm filea
  • force to delete
    1
    rm -f filea
  • wanna a prompt
    1
    rm -i filea
  • delete directories
    1
    2
    3
    rm -r directory 
    or
    rmdir directory

    find

    1
    find /home -name qq
  • find a directory
    1
    find /home -type d -name mydirectory

    help

    1
    2
    help echo
    echo --help

    man

    1
    man ls

    whatis (briefly describe a file)

    1
    whatis cat

    alias

  • set a alias for a command. the alias are saved in ~/.bashrc
    1
    alias foobar='ls la'
  • unlias
    1
    unalias foobar

    exit

  • exit the shell
    1
    2
    3
    exit
    or
    logout

```

  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!

请我喝杯奶茶吧~