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

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

时间: 2025-01-02 03:19:07

Linux Shell command (Quick Study)的相关文章

Linux shell command学习笔记(一)

Key points: Shell种类,echo,$,基本语法,ls,man,su,sudo,grep,ps,clear,cp,rm,cat,more 参考:http://www.jb51.net/LINUXjishu/45329.html Shell的种类有很多种,例如CSH,Bourne Shell,Korn Shell.在现在的大多数Linux发行版中,默认的Shell一般都是Bourne again shell(bash). <echo> echo $SHELL 在Linux中,$符号

Linux shell command学习笔记(二)

<cut> 作用:从输入文件或者命令的输出中析取出各种域 用法:cut –c{字符串范围} –d{字段间分割符} –f{字段索引编号} 举例: (1)查看在线用户:who | cut –c1-8 (2)从系统文件/etc/passwd中获取用户名列表:cut –d: -f1 /etc/passwd [[email protected] ~]$ ls D4C Desktop Documents Downloads Music Pictures process process1 process2

Used Linux Shell Command Before

--run .sh job commandsh .sh --let job run behind stagenohup ./.sh& --met error as below when rub .sh joberror 'XX.sh: line XX: sqlplus:command not found'method: source .bash_profile --delete file, -f(delete directly without remaind)rm -f filename --d

linux shell basic command

Learning basic Linux commands Command Description $ ls This command is used to check the contents ofthe directory. $ pwd This command is used to check the presentworking directory. $ mkdir work We will work in a separate directory calledwork in our h

Requirement-Driven Linux Shell Programming

*/--> Requirement-Driven Linux Shell Programming Table of Contents 1. Where can I find the basic Material about Linux Shell Programming? 2. How to time a function/program(Get the execution time of a program)? 3. How to pass parameters to a function?

linux shell编程

1.什么是shell 2. 还是hello world程序 3. shell中的变量 3.1 系统变量 3.2 用户定义变量 3.2.1 用户定义变量规则 3.2.3 shell如何使用变量 3.2.3 全局变量 vs 局部变量 4. shell编程中的控制结构 4.1 条件判定 4.1.1 简单条件判定 4.1.2 组合判定 4.2  if - else 4.3 for 4.4 while 4.5 case 5. shell中的函数 5.1 函数声明和定义 5.2 函数调用 6. shell脚

Linux Shell脚本攻略(1.8)

1.8 使用别名 linux中的别名就相当于windows中的快捷方式,使用别名可以省去用户输入一长串命令序列的麻烦. 1.8.1 创建临时别名(快捷方式) alias new_command='command sequence' #格式说明 alias install='sudo apt-get install' #实例说明 在声明 install='sudo apt-get install'之后,就可以用install代替'sudo apt-get install'了.使用这种方式声明的别名

Linux Netcat command – The swiss army knife of net

Swiss Army Knife of networking netcat is a versatile tool that is able to read and write data across TCP and UDP network . Combined with other tools and redirection it can be used in number of ways in your scripts. You will be surprised to see what y

Linux shell脚本基础学习详细介绍(完整版)二

详细介绍Linux shell脚本基础学习(五) Linux shell脚本基础前面我们在介绍Linux shell脚本的控制流程时,还有一部分内容没讲就是有关here document的内容这里继续. Linux shell脚本基础已经被分成好几个部分了,这里对控制流程的内容也就马上讲完了,这是最后一部分关于here document,这里举例稍微有点复杂,我们慢慢来分析这个复杂Linux shell脚本. 6. Here documents 当要将几行文字传递给一个命令时,here docu