Linux common commands (two)

A. Linux directory structure

/ root: system administrator

/ bin: to store binary executable files (ls, cat, mkdir , etc. ) , commonly used commands are generally here.

/ boot: storage of various files used during a system boot

/ dev: used to store the device file.

/ etc: storage system management and configuration files

/ home: storage root of all user files, the user's home directory is the starting point

/ var: used to store run-time files need to change the data, but also some of the overflow area large file, say a variety of services such as log file (system startup logs.).

/ lib: storage file system with the program running in the required shared libraries and kernel modules. Dynamically linked shared libraries known as shared libraries, a role similar to windows in the .dll file, store the shared files required to run the root file system.

/ usr: used to store application system , which is the largest directory, use the applications and files to almost all of this directory.

/ usr / bin numerous applications

/ usr / lib common dynamic link library and the package configuration file

II. Directory operations

operating

command

View the current directory

Pwd

Operating Folder

Open the specified directory

Open the current user's home directory

Return to parent directory

Return into the directory

Open the root directory

 

cd [ directory name ]

cd  ~

cd  ..

cd  -

cd  /

Browse the list of files in the directory

View the current directory in the columns of the list of files

Under the current directory to view all files , containing hidden files

View all files in the current directory in the form of columns , contain hidden files

ls

ls -l

ls -a

-the ls

Create a file directory command

New multi-level directory recursive

mkdir directory name

mkdir -p directory name

Delete Files

Delete empty folders

Delete the file / directory deletion mandatory

Asked to delete the

 

rmdir filename

rm -rf file name / directory name

rm -ri

Copy the file / directory

Recursive copy, directory 1 all the files and folders to directory 2

Ask the user before overwriting the original directory when replication

 

cp -r  Contents 1 Contents 2

cp -ri Contents 1 Contents 2

Move or modify the file name

Move files , modify the file name

Directory 1 to move the file to the directory 2 in

 

mv 文件1 文件2

mv 目录1 目录

三. 文件操作

操作

命令

查找文件或目录

find  /root  -name ins

创建文件

touch 文件名

查看,编辑文件

打开文件(输入i,a,o 修改文件)

退出(然后按 :+命令)

保存并退出

强制退出

显示行号

使用字符串1替换字符串1

查看,编辑文件 (按下Ctrl+C退出)

打开一个较小的文件

打开一个新的文件

查看文件开头内容(n表示行数,默认为10)

查看文件的结尾(按下Ctrl+C退出)

动态加载某个文件的内容(常用于查看日志)

查看文件最后几行(n表示行数,默认为10)

 

vi 文件名

Esc

:wq!

:q!

:set nu

:s/字符1/字符串2

 

cat  文件名

cat > 文件名

head -n 文件名

 

tail -f 文件名

tail -n 文件名

四 .权限管理

操作

命令

切换用户

su 用户名

查看登录用户

whoami

查看当前用户所属分组

groups

查看当前用户UIDGID

id

添加用户

useradd [参数] 新建用户账号 

设置用户密码:passwd [用户名]

删除用户:userdel [用户名]

chmod u-r file 给文件file的拥有者减去读的权限

 权限模式

ugo:拥有者,同组用户,其他组用户

+-:赋予,收回权限

 rwx:读,写,执行权限

示例: chmod  r  文件夹名称

  数字模式

  使用三位二进制数表示权限操作

chmod abc file

其中a,b,c各为一个数字,a表示Userb表示Groupc表示Other的权限。

r=4w=2x=1

若要rwx(可读、可写、可执行)属性,则4+2+1=7

若要rw-(可读、可写、不可执行)属性,则4+2=6

若要r-w(可读、不可写、可执行)属性,则4+1=5

范例:

   chmod a=rwx file chmod 777 file 效果相同

   chmod ug=rwx,o=x file chmod 771 file 效果相同

   若用chmod 4755 filename可使此程式具有root的权限

   示例:chmod  753  r  F01

 查看进程 ps

杀死进程 kill -9 pid   -9表示强迫中止

进程文件.sh文件

五 .解压安装

tar安装方式:   tar格式为打包后没有压缩的包,

gz结尾是按照gzip打包并压缩的软件包

tar.bz是按照二进制方式打包并压缩的

示例:

    解压gzip包   tar -zxvf 包名

    解压bz包    tar -jxvf 包名

    解压普通包   tar -xvf 包名

 

 

 

Guess you like

Origin www.cnblogs.com/limengcheng/p/12163401.html