简介
A
ab
accept
ack
ag
alias
apachectl
apk
apropos
apt-get
aptitude
apt-key
apt-sortpkgs
ar
arch
arj
arp
arpd
arping
arptables
arpwatch
as
at
atop
atq
atrm
awk
axel
B
badblocks
base64
basename
batch
bc
bg
bind
blkid
blockdev
bmodinfo
break
builtin
bunzip2
bye
bzcat
bzcmp
bzdiff
bzgrep
bzip2
bzip2recover
bzless
bzmore
C
cal
cancel
cat
cd
cdrecord
chage
chattr
chcon
chfn
chgrp
chkconfig
chmod
chown
chpasswd
chroot
chsh
cksum
clear
clock
clockdiff
cmp
col
colrm
column
comm
command
compress
consoletype
continue
convertquota
cp
cpio
createrepo
crontab
csplit
cu
cupsdisable
cupsenable
curl
cut
D
date
dc
dd
declare
depmod
df
dhclient
dhcpd
dhcrelay
diff
diff3
diffstat
dig
dircolors
dirname
dirs
disown
dmesg
dmidecode
dnf
dnsdomainname
docker
domainname
dos2unix
dpkg-deb
dpkg-divert
dpkg-preconfigure
dpkg-query
dpkg-reconfigure
dpkg-split
dpkg-statoverride
dpkg-trigger
dpkg
dris
dstat
du
dump
E
e2fsck
e2label
echo
ed
edquota
egrep
eject
elinks
elm
emacs
enable
env
ethtool
ex
exec
exit
expand
export
exportfs
expr
F
false
fc
fdisk
fg
fgrep
file
find
findfs
finger
firewall-cmd
fishshell
fmt
fold
fping
free
fsck
ftp
ftpcount
ftpshut
ftptop
ftpwho
fuser
G
gcc
gcov
gdb
get_module
getenforce
getent
getsebool
git
gpasswd
gpm
grep
groupadd
groupdel
groupmems
groupmod
groups
grpck
grpconv
grpunconv
grub
grub2-mkconfig
grub2-set-default
gunzip
gzexe
gzip
H
halt
hcitool
hdparm
head
help
hexdump
history
host
hostid
hostname
hostnamectl
hping3
htdigest
htop
htpasswd
hwclock
I
iconv
id
ifcfg
ifconfig
ifdown
ifstat
iftop
ifup
indent
info
init
inotifywait
insmod
install
iostat
iotop
ip
ip6tables-restore
ip6tables-save
ip6tables
ipcalc
ipcrm
ipcs
iperf
iptables-restore
iptables-save
iptables
iptraf
iptstate
iscsiadm
ispell
J
jed
jobs
joe
join
journalctl
jq
jwhois
K
kernelversion
kexec
kill
killall
L
last
lastb
lastlog
ld
ldconfig
ldd
less
let
lftp
lftpget
lha
lilo
ln
lnstat
local
locate
logger
login
logname
logout
logrotate
logsave
logwatch
look
losetup
lp
lpadmin
lpc
lpq
lpr
lprm
lpstat
ls
lsattr
lsb_release
lsblk
lscpu
lsmod
lsof
lspci
lsusb
ltrace
lvcreate
lvdisplay
lvextend
lvreduce
lvremove
lvresize
lvscan
lynx
M
mail
mailq
mailstat
make
man
mapfile
md5sum
mesg
mii-tool
mkbootdisk
mkcert
mkdir
mke2fs
mkfs
mkinitrd
mkisofs
mknod
mkswap
mktemp
modetest
modprobe
more
mount
mpstat
mtools
mtr
mv
mysql
mysqladmin
mysqldump
mysqlimport
mysqlshow
N
named-checkzone
nano
nc
ncftp
neofetch
nethogs
netstat
newusers
nfsstat
ngrep
nice
nisdomainname
nl
nm
nmap
nmcli
nohup
nologin
nproc
nslookup
ntpdate
ntsysv
O
objdump
od
openssl
P
pacman
parted
partprobe
passwd
paste
patch
pathchk
perl
pfctl
pgrep
php
pico
pidof
pidstat
pigz
ping
ping6
pip
pkexec
pkill
pmap
popd
poweroff
ppp-off
pr
printf
protoize
prtstat
ps
pssh
pstack
pstree
pushd
pv
pvchange
pvck
pvcreate
pvdisplay
pvremove
pvs
pvscan
pwck
pwconv
pwd
pwdx
pwunconv
Q
quota
quotacheck
quotaoff
quotaon
R
rcconf
rcp
read
readelf
readonly
reboot
reject
rename
renice
reposync
repquota
resize
restore
restorecon
return
rev
rexec
rlogin
rm
rmdir
rmmod
route
rpm
rpm2cpio
rpmbuild
rpmdb
rpmquery
rpmsign
rpmverify
rsh
rsync
runlevel
S
sar
scp
screen
script
scriptreplay
sed
seinfo
semanage
sendmail
seq
service
sesearch
set
setfacl
setpci
setsebool
setsid
sftp-server
sftp
sh
sha256sum
shift
shopt
showmount
shuf
shutdown
skill
slabtop
sleep
slocate
smartmontools
smbclient
smbpasswd
sort
source
speedtest-cli
spell
split
squid
squidclient
ss
ssh-add
ssh-agent
ssh-copy-id
ssh-keygen
ssh-keyscan
ssh
sshd
sshpass
startx
stat
strace
strings
stty
su
sudo
sum
supervisord
suspend
swapoff
swapon
sync
sysctl
syslog
systemctl
systool
T
tac
tail
tailf
talk
tar
tcpdump
tcpreplay
tee
telinit
telnet
tempfile
test
tftp
time
timedatectl
times
tload
tmux
top
touch
tput
tr
tracepath
traceroute
trap
tree
true
tty
type
U
ulimit
umask
umount
unalias
uname
unarj
uncompress
unexpand
uniq
unlink
unprotoize
unrar
unset
unzip
updatedb
uptime
useradd
userdel
usermod
usernetctl
users
uucico
uupick
uuto
V
vdfuse
vgchange
vgconvert
vgcreate
vgdisplay
vgextend
vgreduce
vgremove
vgrename
vgscan
vi
vmstat
volname
W
w
wait
wall
watch
wc
wget
whatis
whereis
which
who
whoami
write
X
xargs
xauth
xclip
xhost
xinit
xlsatoms
xlsclients
xlsfonts
xrandr
xset
xz
Y
yes
ypdomainname
yum
Z
zcat
zfore
zip
zipinfo
zipsplit
znew
其他
7z
semanage - Linux命令大全 - 笔下光年
网站首页
semanage
默认目录的安全上下文查询与修改 ## 补充说明 **semanage命令** 是用来查询与修改SELinux默认目录的安全上下文。SELinux的策略与规则管理相关命令:seinfo命令、sesearch命令、getsebool命令、setsebool命令、semanage命令。 ### 语法 ```shell semanage {login|user|port|interface|fcontext|translation} -l semanage fcontext -{a|d|m} [-frst] file_spec ``` ### 选项 ```shell -l:查询。 fcontext:主要用在安全上下文方面。 -a:增加,你可以增加一些目录的默认安全上下文类型设置。 -m:修改。 -d:删除。 ``` ### 实例 查询一下`/var/www/html`的默认安全性本文的设置: ```shell semanage fcontext -l SELinux fcontext type Context ....(前面省略).... /var/www(/.*)? all files system_u:object_r:httpd_sys_content_t:s0 ....(後面省略).... ``` 如上面例子所示,我们可以查询的到每个目录的安全性本文!而目录的设定可以使用正则表达式去指定一个范围。那么如果我们想要增加某些自定义目录的安全性本文呢?举例来说,我想要色设置`/srv/samba`成为 `public_content_t`的类型时,应该如何设置呢? 用semanage命令设置`/srv/samba`目录的默认安全性本文为`public_content_t`: ```shell mkdir /srv/samba ll -Zd /srv/samba drwxr-xr-x root root root:object_r:var_t /srv/samba ``` 如上所示,默认的情况应该是`var_t`这个咚咚的! ```shell semanage fcontext -l | grep '/srv' /srv/.* all files system_u:object_r:var_t:s0 /srv/([^/]*/)?ftp(/.*)? all files system_u:object_r:public_content_t:s0 /srv/([^/]*/)?www(/.*)? all files system_u:object_r:httpd_sys_content_t:s0 /srv/([^/]*/)?rsync(/.*)? all files system_u:object_r:public_content_t:s0 /srv/gallery2(/.*)? all files system_u:object_r:httpd_sys_content_t:s0 /srv directory system_u:object_r:var_t:s0 //看这里! ``` 上面则是默认的`/srv`底下的安全性本文资料,不过,并没有指定到`/srv/samba`。 ```shell semanage fcontext -a -t public_content_t "/srv/samba(/.*)?" semanage fcontext -l | grep '/srv/samba' /srv/samba(/.*)? all files system_u:object_r:public_content_t:s0 ``` ```shell cat /etc/selinux/targeted/contexts/files/file_contexts.local # This file is auto-generated by libsemanage # Please use the semanage command to make changes /srv/samba(/.*)? system_u:object_r:public_content_t:s0 #写入这个档案 ``` ```shell restorecon -Rv /srv/samba* #尝试恢复默认值 ll -Zd /srv/samba drwxr-xr-x root root system_u:object_r:public_content_t /srv/samba/ #有默认值,以后用restorecon命令来修改比较简单! ``` semanage命令的功能很多,这里主要用到的仅有fcontext这个选项的用法而已。如上所示,你可以使用semanage来查询所有的目录默认值,也能够使用它来增加默认值的设置!
上一篇:
seinfo
下一篇:
sendmail