linux系统命令 回顾

解释下什么是 GPL,GNU,自由软件?
GPL:(通用公共许可证):一种授权,任何人有权取得、修改、重新发布自由软件的权力。
GNU:(革奴计划):目标是创建一套完全自由、开放的的操作系统。
自由软件:是一种可以不受限制地自由使用、复制、研究、修改和分发的软件。主要许可证有 GPL 和 BSD 许可证两
种。

linux系统构成:内核+外围程序

uname -r

默认:

[当前用户@主机 工作目录]#/$
可以改变
$PS1

[[email protected] ~]# echo $PS1
[\[email protected]\h \W]\$
You have new mail in /var/spool/mail/root
[[email protected] ~]# PS1=‘\[email protected]\t \$‘
[email protected]:43:15 #
[email protected]:43:16 #

#man bash

内部命令:shell程序一部分,系统启动时驻留在内核中

外部命令:不在shell程序中,其命令过程由shell程序控制

[[email protected] 桌面]# type ls
ls is aliased to `ls --color=auto‘
[[email protected] 桌面]# type cd
cd is a shell builtin
[[email protected] 桌面]# which ls
alias ls=‘ls --color=auto‘
    /bin/ls
[[email protected] 桌面]# which cd
/usr/bin/which: no cd in (/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin)

[[email protected] 桌面]# enable  都是内部命令
enable .
enable :
enable [
enable alias

touch 创建文件和更新时间戳
stat 查看文件状态
[[email protected] ~]# stat 1.txtt
  File: "1.txtt"
  Size: 19            Blocks: 8          IO Block: 4096   普通文件
Device: 802h/2050d    Inode: 10618267    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-04-05 10:31:05.094196869 +0800
Modify: 2017-04-05 10:31:30.275196833 +0800
Change: 2017-04-05 10:31:30.275196833 +0800
[[email protected] ~]# touch 1.txtt
[[email protected] ~]# cat 1.txtt
123456
1sdafafasdf
[[email protected] ~]# stat 1.txtt
  File: "1.txtt"
  Size: 19            Blocks: 8          IO Block: 4096   普通文件
Device: 802h/2050d    Inode: 10618267    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-04-05 10:34:12.915295258 +0800
Modify: 2017-04-05 10:34:06.731295266 +0800
Change: 2017-04-05 10:34:06.731295266 +0800

[[email protected] ~]# echo 1212 >>1.txtt
[[email protected] ~]# stat 1.txtt
  File: "1.txtt"
  Size: 24            Blocks: 8          IO Block: 4096   普通文件
Device: 802h/2050d    Inode: 10618267    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-04-05 10:34:12.915295258 +0800
Modify: 2017-04-05 10:37:34.476433508 +0800
Change: 2017-04-05 10:37:34.476433508 +0800

[[email protected] ~]# tac 1.txtt
111
1212
1sdafafasdf
123456
[[email protected] ~]# cat 1.txtt
123456
1sdafafasdf
1212
111

[[email protected] 桌面]# echo 111 >1.txt
[[email protected] 桌面]# cat 1.txt  >b.txt
[[email protected] 桌面]# cat b.txt
111

做光盘镜像
dd if=/dev/cdrom of=rhel6.iso
cp /dev/cdrom rhel6.iso

cat /dev/cdrom > rehl6.iso

cat 合并文件

[[email protected] 桌面]# cat 1.txt
111
 
[[email protected] 桌面]# cat b.txt
     1    111
[[email protected] 桌面]# cat 1.txt  b.txt >new.txt
[[email protected] 桌面]# cat new.txt
111
     1    111

[[email protected] 桌面]# cat 1.txt
111
adasd
[[email protected] 桌面]# tr ‘a-z‘ ‘A-Z‘  <1.txt  导出
111
ADASD

[[email protected] 桌面]# echo 1212 >>1.txtt
[[email protected] 桌面]# ls -i 1.txtt
10749834 1.txtt
[[email protected] 桌面]# ln 1.txtt hello.txtt
[[email protected] 桌面]# ls -i hello.txtt
10749834 hello.txtt
[[email protected] 桌面]# du -h 1.txtt
4.0K    1.txtt
[[email protected] 桌面]# du -h hello.txtt
4.0K    hello.txtt
[[email protected] 桌面]# md5sum 1.txtt
b5e808f2a41cb05f73fd604ab1b3bda6  1.txtt
You have new mail in /var/spool/mail/root
[[email protected] 桌面]# md5sum hello.txtt
b5e808f2a41cb05f73fd604ab1b3bda6  hello.txtt

——————————
两个小于号
————————————
[[email protected] 桌面]# cat merepo.sh
#!/bin/bash
cat <<EOF > /etc/yum.repos.d/server.repo
[Server]
name=Server
baseurl=ftp://172.40.55.104
enabled=1
gpgcheck=0
EOF

[[email protected] 桌面]# rm -fr  /etc/yum.repos.d/*

[[email protected] 桌面]# sh merepo.sh
[[email protected] 桌面]# ls /etc/yum.repos.d/
server.repo
[[email protected] 桌面]# yum repolist
已加载插件:fastestmirror, refresh-packagekit, security
Determining fastest mirrors
Server                                                   | 4.1 kB     00:00     
Server/primary_db                                        | 3.1 MB     00:00     
仓库标识                              仓库名称                             状态
Server                                Server                               3,819
repolist: 3,819

——————————————————————————————

[[email protected] 桌面]# ls -l $(cat /etc/passwd)

[[email protected] 桌面]# cat /root |xargs ls -l

[[email protected] 桌面]# egrep -n  ‘adm‘ /etc/passwd
4:adm:x:3:4:adm:/var/adm:/sbin/nologin
[[email protected] 桌面]# egrep -n -B2 -A3 ‘adm‘ /etc/passwd
2-bin:x:1:1:bin:/bin:/sbin/nologin
3-daemon:x:2:2:daemon:/sbin:/sbin/nologin
4:adm:x:3:4:adm:/var/adm:/sbin/nologin
5-lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
6-sync:x:5:0:sync:/sbin:/bin/sync
7-shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

[[email protected] 桌面]# egrep --color -o ‘var|dev‘ /etc/passwd
var
var

[[email protected] 桌面]# grep --color root  /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin

[[email protected] 桌面]# grep --color -o root /etc/passwd
root
root

[[email protected] 桌面]# tar acf security.tar.gz security

[[email protected] 桌面]# find /tmp/clu  -type f -exec chmod 644 {} \;

[[email protected] 桌面]# find /tmp/clu  -type d -exec chmod 750 {} \;

vi中 命令补齐:
hostna

ctrl+N  ctrl+P

RPM下载
http://rpmfind.net
http://rpm.pbone.net
http://mirrors.163.com
http://mirrors.aliyun.com

本地rpm包用yum装:可以自动解决依赖关系
yum -y install li*.rpm

|————————————————————————————————————————————————
本地yum缓存先做好,做好后可以拷到不能联网的电脑上,装包时候的依赖就可以用
[[email protected] 桌面]# vim /etc/yum.conf

2 cachedir=/tmp/mypacks
  3 keepcache=1

[[email protected] 桌面]#yum -y install system-config-kickstart

[[email protected] 桌面]#ls /tmp/mypacks/Server/packages/  把这个yum依赖的拷贝就可以
————————————————————————————————————————————————

架构不一样

yum-rhn-plugin-0.9.1-58.el6.noarch.rpm    都可以
zlib-devel-1.2.3-29.el6.i686.rpm          32位
zlib-devel-1.2.3-29.el6.x86_64.rpm        64位

创建用户默认配置文件
[[email protected] 桌面]#vim /etc/login.defs

33 UID_MIN                   660
 34 UID_MAX                 60000

[[email protected] 桌面]# useradd tt
[[email protected] 桌面]# id tt
uid=660(tt) gid=660(tt) 组=660(tt)

/etc/skel

/etc/passwd   /etc/shadow

/etc/group   /etc/gshadow

[[email protected] 桌面]useradd -u 555 zhangsan

[[email protected] 桌面]#vim /root/.bash_history  每次退出 命令都写在这里

[[email protected] 桌面]#vim /root/.bash_logout   (每次退出都删除历史命令)
# ~/.bash_logout
history -c
~

[[email protected] 桌面]# chage -M 90 bob   (指定密码最大天数,-m最小天数)

[[email protected] 桌面]# chage -l  bob   列出密码有效期信息

[[email protected] 桌面]# chage -E 20170605 bob  指定帐号过期时间

[[email protected] 桌面]# chage -d 0 bob   密码立即过期 使用就改密码

[[email protected] ~]# echo "log-$(date +%F).tar.gz"
log-2017-04-05.tar.gz

如果导入了这个私匙信息,就不需要写gpgcheck=0
[[email protected] ~]# rpm --import ftp://172.40.55.104/RPM-GPG-KEY-redhat-release

——————————————————————————————————
chmod -R u=rwX,g=rX,o=rX /tmp/ss  (大X 目录就是755,文件644)

[[email protected] ~]# chmod -R u=rwX,g=rX,o=rX /tmp/ss
[[email protected] ~]# ll -l /tmp/ss
总用量 16
drwxr-xr-x. 116 root root 12288 4月   5 16:45 etc
-rw-r--r--.   1 root root  2031 4月   5 16:44 passwd

————————————————————————————————————————
命令运行期间是由身份的
suid:命令以属主身份运行命令   u+s
   
[[email protected] ~]# chmod u+s /bin/ls
[[email protected] ~]# ll /bin/ls
-rwsr-xr-x. 1 root root 117024 10月 15 2014 /bin/ls
[[email protected] ~]# su - bob
[[email protected] ~]$ ls /root
1.txtt
2.txt

——————————————————
[[email protected] 桌面]# su - bob
[[email protected] ~]$ touch 1.txt

[[email protected] ~]# which touch
/bin/touch
You have new mail in /var/spool/mail/root
[[email protected] ~]# chmod u+s /bin/touch   这是一样的    [[email protected] ~]# chmod 4755/bin/touch

[[email protected] ~]$ touch 2.txt  (这个是以root身份创建的)
[[email protected] ~]$ ll -lhd 1.txt 2.txt
-rw-rw-r--. 1 bob  bob 0 4月   5 16:57 1.txt
-rw-rw-r--. 1 root bob 0 4月   5 16:57 2.txt

————————————————————————————————————————

sgid:继承父目录属组    g+s

[[email protected] ~]# mkdir /tmp/demo

[[email protected] ~]# chgrp bob /tmp/demo       都一样     chown :bob  /tmp/demo
[[email protected] ~]# ll -d /tmp/demo
drwxr-xr-x. 2 root bob 4096 4月   5 17:05 /tmp/demo
[[email protected] ~]# cp /etc/hosts /tmp/demo
[[email protected] ~]# ll /tmp/demo
总用量 4
-rw-r--r--. 1 root root 187 4月   5 17:06 hosts
[[email protected] ~]# chmod g+s /tmp/demo      给目录加了g+s权限后 之后该目录下的文件都是该用户
[[email protected]pc01 ~]# ll -l /etc/passwd
-rw-r--r--. 1 root root 2031 4月   5 15:48 /etc/passwd

[[email protected] ~]# cp  /etc/passwd /tmp/demo
[[email protected] ~]# ll /tmp/demo/
总用量 8
-rw-r--r--. 1 root root  187 4月   5 17:06 hosts
-rw-r--r--. 1 root bob  2031 4月   5 17:07 passwd

sticky bit:用户只能删除自己的文件

[[email protected] 桌面]# setfacl -m u:bob:rwx rem_com.sh    给某一个用户对该文件权限  粘耻位

一个扇区512字节

机械盘 -----》固态盘(开机直接操作不许要等一下)

分区后刷新几种方式:
partx -a /dev/sdb

reboot

分区形式存在的swap性能更高 文件的更差

所以用的时候可以在/etc/fstab中给分区swap和文件的做优先级 使用时

时间: 2024-07-31 07:21:03

linux系统命令 回顾的相关文章

linux系统命令 回顾2

source 和bash/sh 执行脚本时,想立即生效一般设置的环境变量用source,一般的脚本就用bash/sh 当查看硬盘时有空间,存东西说不够用,是因为i节点没了,小文件多,导致i节点没有了.[[email protected] 桌面]# df -hFilesystem            Size  Used Avail Use% Mounted on/dev/sda2             197G   89G   99G  48% /tmpfs                

Linux系统命令

一  进程查看            1   ps  aux     查看当前系统所有运行的进程            -a 显示前台所有进程            -u  显示用户名            -x  显示后台进程            user: 用户名            pid:   进程id.PID     1  init  系统启动的第一个进程            %CPU    cpu占用百分比            %MEM    内存占用百分比         

linux习题回顾

linux习题回顾 1.1 创建一个压缩包/etc,我想让压缩包上面有个日期/时间. [[email protected] ~]# tar zcf /tmp/etc-$(date+%F).tar.gz /etc [[email protected] ~]# ls -l /tmp -rw-r--r--. 1 root root 9731838 Aug  3 19:15 etc-2017-08-03.tar.gz 1.2 已知/oldboy/test.txt文件内容为: oldboy xizi xi

Linux基础回顾(2)——Linux系统分区二三事

问题来自Linux教材,答案自我整理难免会有不足之处.这是我Linux期末的总结 1. 一块硬盘上可以有几种类型的分区?各自可以有多少个?(各个分区能安装操作系统吗?) 硬盘分区有三种类型的分区:主分区,扩展分区,逻辑分区:一个硬盘最多能划分4个主分区,或者3个主分区加上一个扩展分区,扩展分区上可以划分多个逻辑分区(最多20个).能安装操作系统. 2.用户能否在安装过程中创建扩展分区呢? 分区工具在文件系统类型中没有提供扩展(extended)分区类型,即用户不能根据需要不能手工创建扩展分区.安

常用的linux系统命令汇总

top vmstat w & uptime ps && pstree free iostat sar mpstat pmap netstat & ss iptraf tcpdump /proc Nagios Cacti KDE System Guard Gnome System Monitor sysstat 常用的linux系统命令汇总,布布扣,bubuko.com

Linux 系统命令及其使用详解

Linux 系统命令及其使用详解 cat cd chmod chown cp cut名称:cat 使用权限:所有使用者 使用方式:cat [-AbeEnstTuv] [--help] [--version] fileName 说明:把档案串连接后传到基本输出(萤幕或加 > fileName 到另一个档案) 参数:-n 或 --number 由 1 开始对所有输出的行数编号-b 或 --number-nonblank 和 -n 相似,只不过对于空白行不编号-s 或 --squeeze-blank

Linux系统命令练习题

1. 新安装一台RHEL 6.x 或 CentOS 6.x 虚拟机 1)关闭防火墙.SELinux [[email protected] ~]#serviceiptables stop [[email protected] ~]# chkconfigiptables off [[email protected] ~]# vim/etc/sysconfig/selinux ELINUX=disabled 2)使用光盘中的软件包为本机配置YUM源    [ 提示:指到光盘根目录,不要指向Packag

登录linux系统命令提示符显示为:-bash-4.1$

1.问题描述 登录linux系统命令提示符显示如下: -bash-4.1$ -bash-4.1$ 2.原因分析 与用户相关的环境变量的配置文件.bashrc和.bash_profile没了 3.解决方法 /etc/skel当通过 useradd 命令创建新用户,/etc/skel 目录下的文件,都会原封不动的复制到新建用户的家目录下- -bash-4.1$ cp/etc/skel/.bash*   . 4.检查 退出后,重新登录 -bash-4.1$ logout [[email protect

Linux笔记Linux 系统命令及其使用详解(大全)

开机默认界面修改:字符界面和图形界面-->修改ect/inittab文件 Windows远程Telnet访问Linux系统:telnet+远程Linux系统IP地址 Linux目录结构: /:根目录 /bin:存放必要的命令 /boot:存放内核以及启动所需的文件等 /dev:存放设备文件 /etc:存放系统的配置文件 /home:用户文件的主目录,用户数据存放在其主目录中 /lib:存放必要的运行库 /mnt:存放临时的映射文件系统 /proc:存放存储进程和系统信息 /root:超级用户的主