Linux基础shell命令(1)一chmod、adduser、ps等

1.虚拟机.Ubuntu的安装过程
准备镜像:http://cn.ubuntu.com/download/
ubuntu基本上是每年的4月份和10月发布
所以一般版本号:16.04 18.04 20.04
下载镜像一定要长期支持版本:LTS意为“长期支持”,一般为5年。LTS版本将提供免费安全和维护更新至2025年4月。
ubuntu系统现在并且以后将来永远是免费使用。所以才会退出麒麟版
基于Linux操作系统:开源 、可裁剪 、 用户群体广泛

2.Ubuntu是基于Linux系统发行版本之一
RetHat(红帽) Ubuntu Debian

3.安装Ubuntu镜像:
https://baijiahao.baidu.com/s?id=1670100505795119581&wfr=spider&for=pc

vim

1.安装:sudo apt install vim
2.配置:sudo vi /etc/vim/vimrc,在这里面找到这个地方
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set autowrite " Automatically save before commands like :next and :make
set hidden " Hide buffers when they are abandoned
set mouse=a " Enable mouse usage (all modes)

确保上面的set前面的”去掉

然后在后面加两个:
显示行号:set number
自动缩进:set cindent
当前光标哪一行就加一根线:set cursorline

4.vi编辑器

怎么进入编辑模式:i a o(对应的大写也行)
怎么进入命令模式:Esc

复制:yy (3yy)
粘贴:p(粘贴在当前光标的下一行) P(粘贴在当前光标的上一行)
剪切:dd
剪切一个:x
撤销:u
找到最末行:G
查找:/字符串
修改:r (想改什么就后面跟上你要改的)

怎么退出vi编辑器:首先按下Esc

                           ①打出冒号
                           ②q  ---》退出
                               w ---》保存
                              wq ---》保存退出
                              q!---》强制退出

======================================================
man手册
安装:sudo apt install manpages manpages-dev manpages-posix manpages-posix-dev

   1   Executable programs or shell commands (系统命令)
   2   System calls (functions provided by the kernel)(系统调用:操作系统提供的Linux内核提供的)
   3   Library calls (functions within program libraries)(库函数)

   4   Special files (usually found in /dev)
   5   File formats and conventions eg /etc/passwd
   6   Games
   7   Miscellaneous  (including  macro packages and conventions),
       e.g. man(7), groff(7)
   8   System administration commands (usually only for root)
   9   Kernel routines [Non standard]

  要想查找是哪几本有你所需的:man  -f  read
   gec@ubuntu:~$ man -f read
   read (2)             - read from a file descriptor
   read (3posix)        - read from a file
   read (1posix)        - read a line from standard input

 具体想查哪一本:man  1posix read              man 2 read            man 3posix read
          可缩写为     man 1 read                      man 2 read            man 3 read

======================================================================

1.adduser -------->添加用户

含义:新建一个用户,默认会处于一个同名的用户组之中
使用:sudo adduser jack (会在/home下面新建对于用户名字的文件夹)

2.deluser --------->删除用户

含义:删除一个用户,
使用:sudo deluser jack,但这么删除只会删除用户,不会删除在/home下面的jack目录

deluser --remove-home jack(既删除用户同时删除/home家目录下面的对应目录)

3.addgroup ---------->添加用户组

含义:新建一个用户组
使用:sudo addgroup pdd

4.delgroup ----------->删除用户组

查看用户: vi /etc/passwd
查看用户组:vi /etc/group

5.usermod

含义:修改有关用户、用户组关系的命令
使用:
sudo usermod jack -g pdd:将jack的原始用户组指定为pdd
sudo usermod jack -G pdd:将jack添加用户组指定为pdd
sudo usermod jack -a -G pdd:将pdd追加到jack的添加用户组中

6.id

含义:查看当前用户相关的id(比如当前用户id,原始用户id,添加用户组id)
使用:id

7.su

含义:进入用户
使用:su jack

8.exit

含义:退出当前用户或者退出shell
使用:exit

9.whoami

含义:查看自己是哪个用户
使用:whoami

ls -l
gec@ubuntu:~$ ls -l
total 32
-rw-rw-r-- 1 gec gec 87 Aug 29 14:44 1.c
drwxr-xr-x 2 gec gec 4096 Nov 14 2017 Desktop/
drwxrwxr-x 2 gec gec 4096 Nov 22 2017 download/
-rw-r–r-- 1 gec gec 8980 Sep 30 2017 examples.desktop
drwxr-xr-x 3 gec gec 4096 Sep 30 2017 Pictures/
lrwxrwxrwx 1 gec gec 9 Oct 20 2017 share -> /mnt/hgfs
drwxrwxr-x 23 gec gec 4096 Oct 20 2017 utilities/

             u     g   o

- rw-rw-r-- 1 gec gec 87 Aug 29 14:44 1.c
普通文件 所有者 + 所属组 + 其他 1 所有者 所属组 文件大小 最后一次修改时间 文件名
文件类型 文件对各种用户的权限 引用计数
名字个数

r:可读 ①对与普通文件而言意味着可以查看文件内容
②对于目录而言意味着查看目录的内容

w:可写 ①对与普通文件而言意味着可以修改文件内容
②对于目录而言意味着可以增删目录的内容

x:可执行 ①对与普通文件而言意味着可以将文件内容加载到内存
②对于目录而言意味着可以进入该目录

10.chmod

含义:修改权限
使用:chmod u+x,o-r 1.c
chmod 760 1.c

rw- rw- r–
110 110 100
6 6 4

最高权限:777

11.chown / chgrp

含义:修改指定文件的所有者、所属组
使用:sudo chown jack 1.c 将文件1.c的所有者设置为jack
sudo chgrp pdd 1.c 将文件1.c的所属组设置为pdd

在Linux里面一个有七种文件

d:directory 目录
s:socket 套接字
p:pipe 有名管道
b:block 块设备文件
c:character 字符设备文件
l:link 链接文件(软链接或符号链接) 相当于windowns的快捷方式
-:regular 普通文件

12.ps(process state 进程状态)

含义:查看进程的各种信息
用法:ps
ps -ef (多使用)
ps aux

13.top

含义:动态查看进程的状态
使用:top 查看所有进程状态
top -p 178(查看进程号为178的进程状态)

14.kill

含义:向某个进程发信号
使用:kill -l 查看系统所支持的信号
kill -9 1234 向pid为1234的进程发送杀死信号

gec@ubuntu:~$ kill -l

  1. SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
  2. SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
  3. SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
  4. SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
  5. SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
  6. SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
  7. SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
  8. SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
  9. SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
  10. SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
  11. SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
  12. SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
  13. SIGRTMAX-1 64) SIGRTMAX
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值