大家好,今天小编为大家分享关于gg修改器如何用电脑root_电脑可以使用gg修改器吗的内容,赶快来一起来看看吧。
文件名 :/usr/bin/date
1.系统类命令
2.1.1.data 显示日期命令
例:查看当前时间
[root@freeit ~]# date
2015年 04月 28日 星期二 12:34:54 CST
[root@freeit ~]# cal
April 2015
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
参数:
-1:显示当前一个月的日历
-3:显示前一个月、本月、下一个月日历
-s:周日作为第一天显示
-m:周一作为第一天显示
-j:输出的日期为一年的第几天
-y:显示本年度全年日历
-V:显示当前日历版本
[root@freeit ~]# bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty’.
10*10
100
//计算10×10的结果
^C
(interrupt) Exiting bc.
//按ctrl+c退出计算器。
如上个实验:退出计算器
此命令可列出文件行数、单词数、字节数
例:查看/etc/passwd文件的内容
[root@freeit ~]# wc /etc/passwd
41 70 1990 /etc/passwd
//一共41行,70个单次,1990个字节
-c—-查看总的字节数
-w—查看总的单词数
-l —-查看总的行数
[root@freeit ~]# hostname
freeit.
在之前学习的RHEL5.x&6.x系统中,主机名保存文件为/etc/sysconfig/network,修改主机名可以修改此文件,但是要重启系统或者不重启,同时用hostname命令修改当前主机名即可。但是在RHEL7.x的系统中,主机名的配置文件为/etc/hostname.修改主机名的方法也多种多样。如下
—————————————————先查看此时的主机名———————————-
[root@freeit ~]# hostname
freeit.
—————————————————-修改并查看—————————————
[root@freeit ~]# hostname gyh.
[root@freeit ~]# hostname
gyh.
RHEL7.x之前的系统,修改配置文件之后,用hostname查看,主机名不变。要重启才能生效,而7.x的系统,修改配置文件之后,同时用hostname查看,主机名与配置文件实现了同步,这也更加说明了Linux与windows对比的强势,基本上不用重启
——————————-查看此时主机名配置文件内容及此时的主机名———————-[root@freeit ~]# cat /etc/hostname
freeit.
[root@freeit ~]# hostname
freeit.
—————————————–修改配置文件并查看此时的主机名—————————–
[root@freeit ~]# cat /etc/hostname
gyh.
[root@freeit ~]# hostname
gyh.
把主机名修改回freeit开头
使用此命令后弹出如下对话框
直接填写并选择 【OK】退出
查看主机名
[root@freeit ~]# hostname
freeit.
[root@freeit ~]# cat /etc/hostname
freeit.
如上,不仅修改了主机名,同时也修改了配置文件
把主机名改回gyh开头
[root@freeit ~]# hostnamectl set-hostname gyh.
[root@freeit ~]# hostname
gyh.
[root@freeit ~]# cat /etc/hostname
gyh.
同样:不仅修改了主机名,同时也修改了配置文件
2.1.7.uname 查看系统信息(版本&内核)
例:
[root@freeit ~]# uname
Linux
参数说明:
[root@freeit ~]# uname –help
-a, –all 显示系统所有信息
-s, –kernel-name 显示系统内核名
-n, –nodename 显示网络节点主机名(即显示主机名)
-v, –kernel-version 显示内核版本
-m, –machine 查看硬件
-i, –hardware-platform 查看硬件平台
例:
[root@freeit ~]# time
real 0m0.000s
user 0m0.000s
sys 0m0.000s
说明:此命令可以清除当前屏幕的所有内容,只需输入clear回车即可。不做过多说明。
注:ctrl+l快捷键也能起到清屏的作用,更加快捷,方便。
例:
[root@freeit~]# whoami
root
//当前用户为root
[root@freeit ~]# w
09:55:21 up 1:44, 3 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 192.168.10.1 08:13 1.00s 0.60s 0.13s w
root pts/1 192.168.10.1 08:45 4:26 0.24s 0.24s -bash
root tty1 – 08:53 48:48 6.79s 0.31s -bash
[root@freeit ~]# who
root pts/0 2015-04-24 08:13 (192.168.10.1)
root pts/1 2015-04-24 08:45 (192.168.10.1)
root tty1 2015-04-24 08:53
Halt为关机命令,reboot为重启。不做过多说明,请自行实验
[root@freeit ~]# locale -a
aa_DJ
aa_DJ.iso88591
aa_DJ.utf8
aa_ER
aa_ER@saaho
aa_ER.utf8
aa_ER.utf8@saaho
aa_ET
aa_ET.utf8
……
————————————————–修改之前———————————————–
[root@freeit ~]# rm –help
用法:rm [选项]… 文件…
Remove (unlink) the FILE(s).
-f, –force ignore nonexistent files and arguments, never prompt
-i prompt before every removal
-I prompt once before removing more than three files, or
when removing recursively; less intrusive than -i,
while still giving protection against most mistakes
–interactive[=WHEN] prompt according to WHEN: never, once (-I), or
always (-i); without WHEN, prompt always
–one-file-system 递归删除一个层级时,跳过所有不符合命令行参
数的文件系统上的文件
–no-preserve-root do not treat ’/’ specially
–preserve-root do not remove ’/’ (default)
-r, -R, –recursive remove directories and their contents recursively
-d, –dir remove empty directories
-v, –verbose explain what is being done
–help 显示此帮助信息并退出
–version 显示版本信息并退出
默认时,rm 不会删除目录。使用–recursive(-r 或-R)选项可删除每个给定
的目录,以及其下所有的内容。
To remove a file whose name starts with a ’-’, for example ’-foo’,
use one of mands:
rm — -foo
rm ./-foo
请注意,如果使用rm 来删除文件,通常仍可以将该文件恢复原状。如果想保证
该文件的内容无法还原,请考虑使用shred。
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告rm 的翻译错误
要获取完整文档,请运行:info coreutils ’rm invocation’
———————————————–修改之后—————————————————
[root@freeit ~]# LANG=en
[root@freeit ~]# rm –help
Usage: rm [OPTION]… FILE…
Remove (unlink) the FILE(s).
-f, –force ignore nonexistent files and arguments, never prompt
-i prompt before every removal
-I prompt once before removing more than three files, or
when removing recursively; less intrusive than -i,
while still giving protection against most mistakes
–interactive[=WHEN] prompt according to WHEN: never, once (-I), or
always (-i); without WHEN, prompt always
–one-file-system when removing a hierarchy recursively, skip any
directory that is on a file system different from
that of the mand line argument
–no-preserve-root do not treat ’/’ specially
–preserve-root do not remove ’/’ (default)
-r, -R, –recursive remove directories and their contents recursively
-d, –dir remove empty directories
-v, –verbose explain what is being done
–help display this help and exit
–version output version information and exit
By default, rm does not remove directories. Use the –recursive (-r or -R)
option to remove each listed directory, too, along with all of its contents.
To remove a file whose name starts with a ’-’, for example ’-foo’,
use one of mands:
rm — -foo
rm ./-foo
Note that if you use rm to remove a file, it might be possible to recover
some of its contents, given sufficient expertise and/or time. For greater
assurance that the contents are truly unrecoverable, consider using shred.
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report rm translation bugs to <http://translationproject.org/team/>
plete documentation, run: info coreutils ’rm invocation’
例1:查看CPU信息
[root@freeit ~]# more /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name : Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz
stepping : 3
microcode : 0x17
cpu MHz : 2594.080
cache size : 3072 KB
……
例2:CPU运行位数
[root@freeit ~]# getconf LONG_BIT
64
例3:查看CPU型号和逻辑核心数
[root@freeit ~]# cat /proc/cpuinfo |grep name |cut -f2 -d: |uniq -c
2 Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz
例4:查看物理CPU个数
[root@freeit ~]# cat /proc/cpuinfo |grep physical |uniq -c
1 physical id : 0
1 address sizes : 40 bits physical, 48 bits virtual
例5:验证是否支持64位,结果大于0支持64位
[root@freeit ~]# cat /proc/cpuinfo |grep flags |grep ’lm’ |wc -l
1
例6:查看CPU是否支持虚拟化
[root@freeit ~]# cat /proc/cpuinfo |grep flags
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe t aes xsave avx f16c rdrand hypervisor lahf_lm ida arat epb xsaveopt pln pts dtherm fsgsbase smep
注:pae支持半虚拟化。Intel VT支持全虚拟化。
例7:查看内存信息
[root@freeit ~]# more /proc/meminfo
MemTotal: 1010788 kB
MemFree: 729532 kB
MemAvailable: 737372 kB
Buffers: 1080 kB
Cached: 114456 kB
SwapCached: 0 kB
Active: 88088 kB
Inactive: 86136 Kb
……
例8:查看全面硬件信息
[root@freeit ~]# dmidecode |less
# dmidecode 2.12
SMBIOS 2.4 present.
364 structures occupying 16582 bytes.
Table at 0x000E0010.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: Phoenix Technologies LTD
Version: 6.00
Release Date: 07/31/2013
Address: 0xEA050
Runtime Size: 90032 bytes
ROM Size: 64 kB
Characteristics:
……
例9:查看服务器型号
[root@freeit ~]# dmidecode |grep “Product Name”
Product Name: VMware Virtual Platform
Product Name: 440BX Desktop Reference Platform
例10:查看软硬raid信息
————————————————-查看软raid信息——————————————
[root@freeit ~]# cat /proc/mdstat
Personalities :
unused devices: <none>
————————————————–查看硬raid信息——————————————–
[root@freeit ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi4 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi4 Channel: 00 Id: 01 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi4 Channel: 00 Id: 02 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi4 Channel: 00 Id: 03 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi4 Channel: 00 Id: 04 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware SATA CD01 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
例11:查看硬件信息
[root@freeit ~]# lspci
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX – 82443BX/ZX/DX Host bridge (rev 01)
00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX – 82443BX/ZX/DX AGP bridge (rev 01)
00:07.x ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
00:0f.0 patible controller: VMware SVGA II Adapter
00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
……………………
例12:查看开机信息
[root@freeit ~]# dmesg |less
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 3.10.0-121.el7.x86_64 (mockbuild@x86-021.build.eng.bos.) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Tue Apr 8 10:48:19 EDT 2014
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-121.el7.x86_64 root=UUID=49bd8af3-32fb-446a-9104-b562640e5129 ro rd.lvm.lv=rhel/root crashkernel=auto rd.lvm.lv=rhel/swap vconsole.font=latarcyrheb-sun16 vconsole.keymap=us net.ifnames=0 biosdevname=0 rhgb quiet
……
2.目录操作命令
2.2.1.ls 列出目录下的内容及属性信息
[root@freeit ~]# ls /root
1 Documents install.log.syslog Public
anaconda-ks.cfg Downloads Music Templates
Desktop install.log Pictures Videos
[root@freeit www]# pwd
/var/www
————————————查看/var/www这个目录占用的空间大小———————
[root@freeit www]# du
16 ./error/include
212 ./error
4 ./cgi-bin
4 ./html
260 ./icons/small
944 ./icons
1168 .
<默认单位为K>
—————————————-参数说明———————————-
-h:以可读方式显示(带单位显示)
[root@freeit www]# du -h
16K ./error/include
212K ./error
4.0K ./cgi-bin
4.0K ./html
260K ./icons/small
944K ./icons
1.2M .
-s:只显示总大小
[root@freeit www]# du -sh
1.2M .
————————————从/var/www回到/root目录————————
[root@freeit www]# pwd
/var/www
[root@freeit www]# cd /root
[root@freeit ~]# pwd
/root
注:
————————————–在root下创建一个gyh目录————————————
[root@freeit ~]# mkdir /root/gyh
[root@freeit ~]# ls /root
1 Documents install.log Pictures Videos
anaconda-ks.cfg Downloads install.log.syslog Public
Desktop gyh Music Templates
注:如果创建的父级目录不存在,可以使用递归创建参数:-p
[root@freeit ~]# mkdir /root/gyh/aaa
mkdir: cannot create directory ‘/root/gyh/aaa’: No such file or directory
[root@freeit ~]# mkdir -p /root/gyh/aaa
[root@freeit ~]# ls
1 anaconda-ks.cfg gyh ……
-p:parents,递归创建需要的父目录
例:
————————————-删除非空目录gyh————————
[root@freeit ~]# rmdir /root/gyh/
rmdir: failed to remove ‘/root/gyh’: Directory not empty
————————————–删除空目录aaa——————————-
[root@freeit ~]# ls /root/gyh/
aaa
[root@freeit ~]# rmdir /root/gyh/aaa
[root@freeit ~]# ls /root/gyh/
3.文件操作命令
2.3.1.df 报告文件系统的总容量、使用量、剩余量、挂载情况
—————————————–查看sda的使用情况——————————–
[root@freeit ~]# df /dev/sda
Filesystem 1K-blocks Used Available Use% Mounted on
– 315904 212 315692 1% /dev
例1:查找/目录下user1用户的所有文件,并拷贝到/root/findfile中
[root@freeit ~]#find / -user user1 –exec /bin/cp –rf {} /root/findfile ;
参数说明:
-user:按文件属主查找
-name:按文件名字查找
-group:按文件属组查找
-perm:按文件权限查找
-atime –n:使用时间在N天以内
-atime +n:使用时间在N天以前
-mtime –n:内容改变时间在N天以内
-mtime +n:内容改变时间在N天以前
-ctime -n:文件状态改变时间在N天内
-ctime +n:文件状态改变时间在N天前
-size +1000000c –print :查找文件长度大于1M字节的文件
注:
例2:查找user1的所有文件
[root@freeit ~]# find / -user user1
find: ‘/proc/9538/task/9538/fd/6’: No such file or directory
find: ‘/proc/9538/task/9538/fdinfo/6’: No such file or directory
find: ‘/proc/9538/fd/6’: No such file or directory
find: ‘/proc/9538/fdinfo/6’: No such file or directory
/tmp/user1
/var/spool/mail/user1
/home/user1
/home/user1/.mozilla
/home/user1/.mozilla/extensions
/home/user1/.mozilla/plugins
/home/user1/.bash_logout
/home/user1/.bash_profile
/home/user1/.bashrc
/home/user1/.cache
/home/user1/.cache/abrt
/home/user1/.cache/abrt/lastnotification
/home/user1/.config
/home/user1/.config/abrt
/home/user1/.bash_history
whereis:查找一个命令相关信息放在那里(查找命令的目录);
which:查看当前要执行的命令所在的路径;
—————————————查找ls命令的存放目录———————————-
[root@freeit ~]# whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz
—————————————查看ls命令所在路径——————————————-
[root@freeit ~]# which ls
alias ls=’ls –color=auto’
/usr/bin/ls
—————————–过滤出/etc/passwd中user1用户所在行—————————-
[root@freeit ~]# cat /etc/passwd |grep user1
user1:x:501:501::/home/user1:/bin/bash
通俗讲就是:本命令以不可编辑文本方式显示文件的内容(而Vim是可以编辑的)
———————————-查看/etc/passwd文件内容————————————
[root@freeit tmp]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
rtkit:x:499:496:RealtimeKit:/proc:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
saslauth:x:498:76:”Saslauthd user”:/var/empty/saslauth:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
pulse:x:497:494:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
xguest:x:500:500:Guest:/home/xguest:/bin/bash
sabayon:x:86:86:Sabayon user:/home/sabayon:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
named:x:25:25:Named:/var/named:/sbin/nologin
dhcpd:x:177:177:DHCP server:/:/sbin/nologin
user1:x:501:501::/home/user1:/bin/bash
user2:x:502:502::/home/user2:/bin/bash
由于无法以图文演示本命令,请自行验证。
注:Ctrl+b向上翻一页
Ctrl+m向下翻一行
空格,向下翻一页
说明:当我们直接在真机上使用命令时,有时候查看一个文件或目录内容(一页显示不完),系统默认全部显示,但是不能像windows一样上下滚动显示。
我们可以利用less命令一页一页的显示,但是也是不可逆的,不能往回看
例:查看/etc/passwd内容
[root@freeit ~]# less /etc/passwd
按空格键向下翻页。
例:
———————————-复制/etc/passwd到/tmp下————————————–
[root@freeit tmp]# pwd
/tmp
[root@freeit tmp]# ls
[root@freeit tmp]# cp /etc/passwd .
[root@freeit tmp]# ls
passwd
常用参数:
-p:带权限复制
此命令的使用与windows中的剪切命令功能一样。但是在Linux中,移动的同时,也可以改名。
—————————————把/root下的gyh文件移动到/tmp————————
[root@freeit tmp]# ls /root/
1 anaconda-ks.cfg gyh ……
[root@freeit tmp]# mv /root/gyh /tmp/
[root@freeit tmp]# ls
gyh passwd
————————————–把/tmp下的gyh改名为gyh.bak—————————-
[root@freeit tmp]# mv gyh gyh.bak
[root@freeit tmp]# ls
gyh.bak passwd
[root@freeit tmp]#
——————————————删除/tmp文件下的passwd————————–
[root@freeit tmp]# pwd
/tmp
[root@freeit tmp]# ls
gyh.bak passwd
[root@freeit tmp]# rm passwd
rm: remove regular file ‘passwd’? y
[root@freeit tmp]# ls
gyh.bak
//删除成功
常用参数:
-r:删除目录
-f:强制删除,不提示直接删除
———————————–在/tmp目录下创建一个空文件gyh———————————–
[root@freeit tmp]# pwd
/tmp
[root@freeit tmp]# touch gyh
[root@freeit tmp]# ls
gyh
例:查看/etc/passwd文件的前10行内容,对照上面cat显示的内容验证
[root@freeit tmp]# head /etc/passwd |nl
1 root:x:0:0:root:/root:/bin/bash
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
8 halt:x:7:0:halt:/sbin:/sbin/halt
9 mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
10 uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
注:
例:查看/etc/passwd文件的后10行内容,参照cat显示内容
[root@freeit tmp]# tail /etc/passwd |nl
1 mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
2 pulse:x:497:494:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
3 xguest:x:500:500:Guest:/home/xguest:/bin/bash
4 sabayon:x:86:86:Sabayon user:/home/sabayon:/sbin/nologin
5 sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
6 tcpdump:x:72:72::/:/sbin/nologin
7 named:x:25:25:Named:/var/named:/sbin/nologin
8 dhcpd:x:177:177:DHCP server:/:/sbin/nologin
9 user1:x:501:501::/home/user1:/bin/bash
10 user2:x:502:502::/home/user2:/bin/bash
4.ln链接
2.4.1.软链接
软链接也叫做符号链接,相当于windows中的快捷方式。做完链接之后,链接文件的大小不变,不管源文件怎么变化。
——————————————-/mnt目录下创建gyh.text文件———————————-
[root@freeit tmp]# touch /mnt/gyh.text
[root@freeit tmp]# ll /mnt/
total 0
-rw-r–r–. 1 root root 0 Apr 28 19:11 gyh.text
//大小为0
——————————————把此文件连接到/tmp下并查看大小—————————–
[root@freeit tmp]# ln -s /mnt/gyh.text ./gyh
[root@freeit tmp]# ll
total 0
lrwxrwxrwx. 1 root root 13 Apr 28 19:25 gyh -> /mnt/gyh.text
链接之后大小为13K
——————————————向源文件中导入内容————————————————-
[root@freeit tmp]# cat /etc/inittab >/mnt/gyh.text
[root@freeit tmp]# ll /mnt/gyh.text
-rw-r–r–. 1 root root 491 Apr 28 19:31 /mnt/gyh.text
//大小变为491
——————————————-查看连接文件/tmp/gyh的大小————————————
[root@freeit tmp]# ll
total 0
lrwxrwxrwx. 1 root root 13 Apr 28 19:25 gyh -> /mnt/gyh.text
//链接文件的大小没有变
注:
软连接相当于windows中的快捷方式,源文件删除之后,链接即失效。
硬链接主要用于同步备份使用,源文件的大小变化,也会同步到链接文件。
———————————/mnt目录下创建gyh.text文件————————————————–
[root@freeit tmp]# touch /mnt/gyh.text
[root@freeit tmp]# ls /mnt/
gyh.text
———————————把此文件硬链接到/tmp下——————————————————-
[root@freeit tmp]# ln -n /mnt/gyh.text /tmp/gyh
[root@freeit tmp]# ll
total 0
-rw-r–r–. 2 root root 0 May 3 19:33 gyh
//大小为0
—————————————–向源文件gyh.text导入内容——————————————
[root@freeit tmp]# cat /etc/passwd >/mnt/gyh.text
[root@freeit tmp]# ll /mnt
total 4
-rw-r–r–. 2 root root 1926 May 3 19:36 gyh.text
//源文件导入内容后大小发生变化:1926
———————————————-查看链接文件的大小———————————————-
[root@freeit tmp]# ll
total 4
-rw-r–r–. 2 root root 1926 May 3 19:36 gyh
//大小与源文件一样,同步增长
———————————————–删除源文件,验证连接文件是否还能用——————–
[root@freeit tmp]# rm -rf /mnt/gyh.text
[root@freeit tmp]# cat gyh
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
unbound:x:998:997:Unbound DNS resolver:/etc/unbound:/sbin/nologin
colord:x:997:996:User for colord:/var/lib/colord:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
saslauth:x:996:76:”Saslauthd user”:/run/saslauthd:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
libstoragemgmt:x:995:994:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
chrony:x:994:993::/var/lib/chrony:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:993:991::/run/gnome-initial-setup/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
freeit_gyh:x:1000:1000:freeit_gyh:/home/freeit_gyh:/bin/bash
//源文件删除之后,链接文件仍然可用,由此可以看出,硬链接的文件也能起到备份的作用
5.权限操作
2.5.1.文件权限介绍
格式:(-rw-r–r–)
[root@freeit ~]# ls -l /etc/passwd
-rw-r–r–. 1 root root 1926 Dec 11 22:59 /etc/passwd
chmod [OPTION]… MODE[,MODE]… FILE…
#chmod 777 file1
参数设置
a 所有用户
u 创建者
g 同组用户
o 其他用户,除去创建者和同组用户之外的用户
+ 增加权限
– 清除权限
= 设置唯一权限
常用设置
g+w — 增加组用户的写权限
o-rwx — 清除其他用户的全部访问权限
u+x — 允许文件属主执行文件
a+rw — 允许所有用户读和写文件
ug+r — 允许文件属主和属组用户读文件
g=rx — 设置属组用户只能读和执行文件(不可写)
通过增加 -R 参数(递归),可以改变整个目录树的权限。
#chmod o+w sneakers.txt
#chmod go-rw sneakers.txt
#chmod a-rw sneakers.txt
例:创建一个文件/tmp/onepice.txt,修改权限,所有者rwx,所属组和其他用户rw权限
[root@freeit tmp]# chmod u=rwx onepice.txt
[root@freeit tmp]# ll
total 0
-rwxr–r-x. 1 root root 0 May 6 08:29 onepice.txt
[root@freeit tmp]# chmod g+rw onepice.txt
[root@freeit tmp]# ll
total 0
-rwxrw-r-x. 1 root root 0 May 6 08:29 onepice.txt
[root@freeit tmp]# chmod o+rw onepice.txt
[root@freeit tmp]# ll
total 0
-rwxrw-rwx. 1 root root 0 May 6 08:29 onepice.txt
注:权限的附加,可以使用“+”,也可以使用“=”。
命令:
getfacl:查看文件的acl权限。
setfacl:设置文件的acl权限。
简介:
使用chmod命令,可以为文件设置权限,设置对象有宿主、所属组、其他用户。但是,chmod设置的权限是大方向的,并不能针对具体的用户进行权限的设置,所以引入了acl权限。具体使用看下面的例子
例:依然拿上面的onepice.txt文件为例,查看其acl权限,然后针对具体用户设置:user1用户只有读(r)的权限,user2用户有读写(rw)的权限。
[root@freeit tmp]# pwd
/tmp
[root@freeit tmp]# ls
onepice.txt
[root@freeit tmp]# getfacl onepice.txt
# file: onepice.txt //文件名
# owner: root //文件所有者
# group: root //文件所属组
user::rwx //文件所有者的权限
group::rw- //文件所属组的权限
other::rwx //其他用户对文件的权限
——————————————-针对user1、user2设置acl———————————————
[root@freeit tmp]# setfacl -m u:user1:r– onepice.txt
//对user1设置acl权限
[root@freeit tmp]# setfacl -m u:user2:rw- onepice.txt
//对user2设置acl权限
[root@freeit tmp]# getfacl onepice.txt
# file: onepice.txt
# owner: root
# group: root
user::rwx
user:user1:r– //user1只有读的权限
user:user2:rw- //user2只有rw权限
group::rw-
mask::rw-
other::rwx
———————————————验证———————————————————–
[root@freeit tmp]# su user1
[user1@freeit tmp]$ cat onepice.txt
[user1@freeit tmp]$
//user1可以查看,由于文件为空,所以查看内容为空
[user1@freeit tmp]$ head /etc/passwd >onepice.txt
bash: onepice.txt: Permission denied
//写入内容被拒绝,无权限
[root@freeit tmp]# su user2
[user2@freeit tmp]$ head /etc/passwd >onepice.txt
[user2@freeit tmp]$ cat onepice.txt
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
//user2可以写入内容,并且能够查看,有读写的权限
以上就是关于gg修改器如何用电脑root_电脑可以使用gg修改器吗的全部内容,希望对大家有帮助。