前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >linux学习笔记一

linux学习笔记一

作者头像
热心的社会主义接班人
发布2018-04-27 13:33:13
7380
发布2018-04-27 13:33:13
举报
文章被收录于专栏:cscscs

基础命令。


shell命令的格式: 命令名 [选项] [参数] 选项前面有一个减号–,与参数区分(参数没有减号)。 如 ls -ah。

root@kali:~# ls -ah
.      2.txt  .bash_history  .cache   Documents  .gconf         .local    .msf4     .profile  succeed.txt  .viminfo
..     3.txt  .bashrc        .config  Downloads  .gnupg         ml.txt    Music     Public    Templates
1.txt  a.txt  b.txt          Desktop  end.txt    .ICEauthority  .mozilla  Pictures  .rnd      Videos

who 显示当前已经登录系统的所有用户,登录时间。

root@kali:~# who
root     tty2         2017-11-02 20:40 (:1)

whatis 命令名 ,查询命令的简单功能,比如whatis cp.

root@kali:~# whatis cp
cp (1)               - copy files and directories

--help 显示指定命令的帮助信息,date --help.

root@kali:~# date --help
用法:date [选项]... [+格式]
 或:date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.
......我省略了

info 命令名,查询命令名的用法或者文件格式. history [数字] 查看shell历史记录。

root@kali:~# history 3
  165  history 
  166  info 3
  167  history 3

linux基础知识


/usr/share/doc 帮助文档存放地。

root@kali:~# ls -ah /usr/share/doc
.                                       libfreetype6                        m4
..                                      libfreexl1                          macchanger
0trace                                  libfribidi0                         magicrescue
aapt                                    libfuse2                            magictree
acccheck                                libfwupd1                           mailutils
accountsservice                         libfyba0                            mailutils-common
ace-voip                                libgail18                           make

linux几个主要和shell有关的配置文件。 1 /etc/profile 系统最重要的shell配置文件,也是系统开机 最先检查的文件。

root@kali:~# cat /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else

2 ~/.bash_profile 文件,每一个用户bash环境配置 文件。 3 ~/.bash_history 文件,保存用户历史记录。

root@kali:~# cat ~/.bash_history 
service postgresql start 
msfconsole 
ping 192.168.201.135
ifconfig -a
ping 192.168.201.135
ping 127.0.0.1
ping 127.0.0.1 -3

4 ~/.bashrc 文件,每次运行bash时读取,定义终端的设置以及shell提示符。

root@kali:~# cat ~/.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

文件查看 cat [选项] 文件列表,查看短小文件 -n可以显示行号。

root@kali:~# cat -n 1.txt
     1  ot@kali:~# ifconfig -a
     2  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
     3          inet 192.168.201.133  netmask 255.255.255.0  broadcast 192.168.201.255
     4          inet6 fe80::20c:29ff:fecc:87cf  prefixlen 64  scopeid 0x20<link>
     5          ether 00:0c:29:cc:87:cf  txqueuelen 1000  (Ethernet)

more 分屏显示文本文件,按enter显示下一行,space显示下一屏。 less 与more类似,可以使用上下剪头,enter,space,q退出。


文件和账户


查看文件摘要 head [选项] 文件 显示文本开头问题,默认前10行, -n 数字 ,指定行数。

root@kali:~# head -n 3 1.txt
ot@kali:~# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.201.133  netmask 255.255.255.0  broadcast 192.168.

tail 显示文本的结尾部分,默认后10行,-n 数字 指定行数。

root@kali:~# tail -n 3 1.txt
[*] Exploit completed, but no session was created.
msf exploit(ms08_067_netapi) > 

分析文本 wc [选项] 文件 -c 显示文件字节数。 -l 显示文件的行数 -w 显示文件单词数 sort [选项] 文件列表 -r 反向排序。 -n 数字大小排序。 列子: ls -l | sort -n -r -k 6

root@kali:~# wc -clw 1.txt
  81  459 4048 1.txt
root@kali:~# ls -l|sort -n -r -k 3
总用量 120
-rw-r--r-- 1 root root  8122 10月 27 08:39 succeed.txt
-rw-r--r-- 1 root root  6144 10月 27 23:08 b.txt
-rw-r--r-- 1 root root  5724 10月 27 02:32 a.txt
-rw-r--r-- 1 root root  4048 10月 26 21:50 1.txt
-rw-r--r-- 1 root root 29378 10月 26 20:10 end.txt

账号与密码 用户账号信息文件 /etc/passwd 用户数据库文件,保存除密码之外的用户账号信息。

root@kali:~# cat /etc/passwd 
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync

用户密码信息文件 /etc/shadow 根据/etc/passwd文件产生,超级用户查看。

root@kali:~# cat /etc/shadow 
root:$6$1gbbY3hN$Gu10DwK0pzBhoWOHL6hw0cIjESciqLIFZPvIf7o31rcPHXltY9m56Kq8jftdi9M3tqcLQjrYdoux3fb8SQthe0:17464:0:99999:7:::
daemon:*:17426:0:99999:7:::
bin:*:17426:0:99999:7:::
sys:*:17426:0:99999:7:::
sync:*:17426:0:99999:7:::
games:*:17426:0:99999:7:::

用户管理命令 创建用户 useradd [选项] 用户名 修改密码 passwd [选项] [用户] -d 删除用户密码。 创建新用户,必须设置初始密码,否则账号禁止被登录。 userdel 用户名 useradd satan passwd satan passwd -d satan user satan

root@kali:~# useradd satan
root@kali:~# passwd satan
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码
root@kali:~# passwd -d satan
passwd:密码过期信息已更改。

su [用户名],切换用户,无用户名参数,切换超级用户。

修改文件权限 修改文件所有权 chown 文件拥有人 文件


**近来事情比较多,双十一后就有时间了,到时候更上进度。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017.11.02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 基础命令。
  • linux基础知识
  • 文件和账户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档