Linux Shell command (Quick Study)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux Shell command (Quick Study)相关的知识,希望对你有一定的参考价值。

cd /  : entry root directory
-----------------------
[email protected]:/etc$ cd /
[email protected]:/$ pwd


cd ~  : entry user root directory
----------------------
[email protected]:/$ cd ~
[email protected]:~$ pwd
/home/tangym

ls    : list all files.
pwd   : show current directory
cd /home :  entry home directory
cd .. : entry the last parent directory

cat fstab: show the text file content.

cat fs, then press <Tab>. Shell will fill the whole file name automtically.
ls m*  : list all the file name starts with: m
ls magi?  : list all the file name starts with : magi and following one character.
          Like: magic
ls m*[od]  : list all starts with : m, end with: o or d.
ls -l   : show all file‘s properties:
-------------------------
[email protected]:~$ ls -l
total 204112
drwxr-xr-x  2 tangym tangym      4096 May 29  2015 Desktop
drwxr-xr-x  2 tangym tangym      4096 May 29  2015 Documents
drwxr-xr-x  3 tangym tangym      4096 May 14 08:53 Downloads
-rw-r--r--  1 tangym tangym      8445 May 29  2015 examples.desktop
-rw-rw-r--  1 tangym tangym     10240 Jan 20  2011 ez_setup.py
drwxr-xr-x  2 tangym tangym      4096 May 29  2015 Music
drwxr-xr-x  2 tangym tangym      4096 May 29  2015 Pictures
drwxr-xr-x  2 tangym tangym      4096 May 29  2015 Public

dir : show all files
vdir: show all files and its properties

cat -n .bashrc: show file content with rowcount
---------------------------
[email protected]:~$ cat -n .bashrc
     1 # ~/.bashrc: executed by bash(1) for non-login shells.
     2 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
     3 # for examples
     4 

more .bashrc : show file content in separate page.
----------------
[email protected]:~$ more .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

head -n 5 .bashrc : show first 5 row content
tail -n 5 .bashrc    : show last 5 row content.

grep PS1 .bashrc    : find all row content with: PS1
------------------------
[email protected]:~$ grep PS1 .bashrc
[ -z "$PS1" ] && return
    PS1=‘${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ‘
    PS1=‘${debian_chroot:+($debian_chroot)}\[email protected]\h:\w\$ ‘
    PS1="\[\e]0;${debian_chroot:+($debian_chro

find ./ -name *bash*  : Find file name with: bash in current directory.
-----------------------------
[email protected]:~$ find ./ -name *bash*
./.bash_history
./.bashrc
./.bash_logout
./redis-py-master/vagrant/.bash_profile
./Downloads/redis-py-master/vagrant/.bash_profile

[email protected]:~$ locate bash  // similar to find . find file/directory with :back

[email protected]:~$ sudo updatedb //force update local db for Locate command
[email protected]:~$ firefox www.baidu.com : open firefox webbrowser

whereis find  : get command‘s notebook

-------------------------------
[email protected]:~$ whereis find : get notebook
find: /usr/bin/find /usr/bin/X11/find /usr/share/man/man1/find.1.gz
[email protected]:~$ whereis -b find
---------------get executable program
find: /usr/bin/find /usr/bin/X11/find

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


which ls: find where is ls command
------------------------------
[email protected]:~$ which ls
/bin/ls

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

who
whoami
uname
uname -a
uname -r
: kernel version
----------------------------
[email protected]:~$ who
tangym   tty7         2016-05-23 23:50
tangym   pts/1        2016-05-23 23:50 (:0)
tangym   pts/2        2016-05-23 23:58 (:0)
tangym   pts/3        2016-05-23 23:59 (:0)
tangym   pts/4        2016-05-24 19:49 (:0)
[email protected]:~$ who am i
tangym   pts/4        2016-05-24 19:49 (:0)
[email protected]:~$ whoami
tangym
[email protected]:~$ uname
Linux
[email protected]:~$ uname -a
Linux ubuntu 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

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

man find  : get the find command decription

-------------------------------
[email protected]:~$ man find

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

whatis ls: get the command common usage.

-------------------------------
[email protected]:~$ whatis ls
ls (1)               - list directory contents

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



本文出自 “软件设计与开发” 博客,请务必保留此出处http://yuanzhitang.blog.51cto.com/2769219/1782968

以上是关于Linux Shell command (Quick Study)的主要内容,如果未能解决你的问题,请参考以下文章

Linux shell command学习笔记

linux shell学习四

Linux Shell command (Quick Study)

Linux shell command学习笔记

Linux主要shell命令详解

Linux shell 命令运行符 &,;,&& 区别