1.linuxlocate
linuxlocate
linuxæ¥è¯¢å½ä»¤ï¼1.find
findæ¯æ常è§åæ强大çæ¥æ¾å½ä»¤ï¼ä½ å¯ä»¥ç¨å®æ¾å°ä»»ä½ä½ æ³æ¾çæ件ã
2.locate
locateå½ä»¤å ¶å®æ¯find-nameçå¦ä¸ç§åæ³ï¼ä½æ¯è¦æ¯åè å¿«å¾å¤ï¼åå å¨äºå®ä¸æç´¢å ·ä½ç®å½ï¼èæ¯æç´¢ä¸ä¸ªæ°æ®åºã
3.whereis
whereiså½ä»¤åªè½ç¨äºç¨åºåçæç´¢ï¼èä¸åªæç´¢äºè¿å¶æ件ï¼åæ°-bï¼ãman说ææ件ï¼åæ°-mï¼åæºä»£ç æ件ï¼åæ°-sï¼ã
4.which
whichå½ä»¤çä½ç¨æ¯ï¼å¨PATHåéæå®çè·¯å¾ä¸ï¼æç´¢æ个系ç»å½ä»¤çä½ç½®ï¼å¹¶ä¸è¿å第ä¸ä¸ªæç´¢ç»æã
5.type
typeå½ä»¤å ¶å®ä¸è½ç®æ¥æ¾å½ä»¤ï¼å®æ¯ç¨æ¥åºåæ个å½ä»¤å°åºæ¯ç±shellèªå¸¦çï¼è¿æ¯ç±shellå¤é¨çç¬ç«äºè¿å¶æ件æä¾çã
linuxä¸cè¯è¨åºå½æ°ç®å½ï¼
ä¸è¬æ¥è¯´æ¯æ¾å¨/usr/includeç®å½ä¸çï¼
ä½æ¯è¿ä¸ªå¹¶ä¸å±éä¹æ¯å¯æ§çï¼å¦ææ们è¿è¡å¼åè¿ç¨ä¸ï¼å°±ä¼å¨å æ ¸çåºå½æ°æ件ç®å½ï¼
ä¾å¦å¨:/XXX/XXX/linux-X.X/include
æä»¥æ ¹æ®ä¸åçæ åµï¼å¤´æ件åæ¾çç®å½ä¹æ¯ä¸åçï¼å ·ä½éè¦å¯ä»¥æ ¹æ®locateågrepå½ä»¤è¿è¡æ¥è¯¢ã
å¦ä½å¨linuxä¸ç¨å½ä»¤å®ç°ç¨æ·åç»ç管çï¼
Linuxä¸ç¨å½ä»¤å®ç°æ¬å°ç¨æ·åç»ç管ç
æ¬å°ç¨æ·åç»ï¼ç®¡çæ件åè¿ç¨çç
æ¬å°ç¨æ·åç»ï¼
1ï¼root:è¶ çº§ç®¡çåç³»ç»å建ç第ä¸ä¸ªè´¦æ·
ç¹ç¹ï¼
id为:0
家ç®å½ï¼/root
å ·æç³»ç»çå®å ¨æ§å¶æ:å°å¿ä½¿ç¨ã
#id
uid=0(root)gid=0(root)groups=0(root)context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c
#
2ï¼æ®éç¨æ·ï¼ä¸å ·æ管çåæé
ç¹ç¹ï¼
idèå´ï¼
=id=
家ç®å½ï¼/home/ç¨æ·å
#idstudent
uid=(student)gid=(student)groups=(student),源码源码intvalue源码(wheel)
#
3ï¼æå¡ç¨æ·ï¼ä¸ºæå¡æä¾æé
ç¹ç¹ï¼
idèå´ï¼
0id
家ç®å½ï¼åºç¨ç¨åºæå¡ç®å½
#idapache
uid=(apache)gid=(apache)groups=(apache)
#
å¦ææ¯yumï¼rpmå®è£ ç软件ï¼ç±rpmå ä¸çèæ¬å建æå¡è´¦æ·
Includeconf.modules.d/*.conf
#
#Ifyouwishhttpdtorunasadifferentuserorgroup,youmustrun
#httpdasrootinitiallyanditwillswitch.
#
#User/Group:Thename(or#number)oftheuser/grouptorunhttpdas.
#Itisusuallygoodpracticetocreateadedicateduserandgroupfor
#runninghttpd,aswithmostsystemservices.
#
Userapache
Groupapache
#'Main'serverconfiguration
#
æ¬å°ç»ï¼
1ï¼ä¸»ç»ï¼ä¸ä¸ªç¨æ·ä¸å®è¦å±äºæ个主ç»ä¸ãå½äºç¨æ·å¨å建æ件æ¶ï¼ç»æ件çå½å±ç»
2ï¼ä»å±ç»ï¼ç¨æ·å®¹å¨ï¼ç»ç»å管çç¨æ·æé管æ§
ä½ç¨ï¼
æ件ï¼
è¿ç¨ï¼
$ps-ux
USERPID%CPU%MEMVSZRSSTTYSTATSTARTTIMECOMMAND
student..?Ss::/usr/lib/system
student..?S::(sd-pam)
student..?S::sshd:student@p
student..pts/0Ss::-bash
student..?D::sshd:student@p
student..pts/1Ss::-bash
student..pts/1S::/bin/bash
student..pts/1R+::ps-ux
$
è´¦æ·æ件ï¼
1ï¼/etc/passwd:ä¿åç¨æ·ä¿¡æ¯
#cat/etc/passwd|grepstudent
student:x:::StudentUser:/home/student:/bin/bash
ç¨æ·åå¯ç uid主ç»IDæ述家ç®å½ç»å½shell
#
#cat/etc/passwd|grep-wroot:x
root:x:0:0:root:/root:/bin/bash
#
#cat/etc/passwd|grepapache
apache:x:::Apache:/usr/share/httpd:/sbin/nologin
æå¡è´¦å·æ æ³ç»å½ç³»ç»
#
2./etc/shadowï¼ä¿åç¨æ·å¯ç çHASHï¼å¯ç çæææ§ä¿¡æ¯ï¼å¯ç ä¿®æ¹æ¶é´ï¼è´¦æ·æææã
#
#ls-l/etc/shadow
----------.1rootrootMar:/etc/shadow
#
#
#cat/etc/shadow|grepstudent
student:$6$8oIjLCsc$/n1iQXYh1E6.uOEuJKgioqAtmqm2TQmkJGF2RwyteIr1tIfrPdiRYgWe6Sjen5/eMij2uHM/a1tue/QRlo3X::0::7:::
#
å¯ç çHASH:sha
8oIjLCsc$/n1iQXYh1E6.uOEuJKgioqAtmqm2TQmkJGF2RwyteIr1tIfrPdiRYgWe6Sjen5/eMij2uHM/a1tue/QRlo3X
:天æ°å¯ç æåä¸æ¬¡ä¿®æ¹çæ¶é´ä»--+天ä¹åé£ä¸å¤©
0ï¼å¯ç æå°ä½¿ç¨å¤©æ°0没æéå¶ç¨æ·éæ¶å¯ä»¥æ¹å¯ç
ï¼å¤©æ°ï¼å¯ç æ大修æ¹æ¶é´æ°¸ä¹ å¤å¹´
7ï¼warningè¦åæ¶é´ï¼å½å¯ç å¿«å°æåä¿®æ¹æ¶é´å7天ï¼éç¥ç¨æ·ä¿®æ¹ã
::天æ°å¤±ææ¶é´inactiveç¨æ·å¯ç è¿äºæåä¿®æ¹æ¶é´ï¼æªæ¹åå¯ç ï¼åè¿å¤å°å¤©ï¼è´¦æ·å°è¢«éå®
::è´¦æ·æææ
å建ç¨æ·åç»ï¼
å建æ¶ï¼æ²¡æå¯ç ï¼
#useraddzhangsan
#useraddlisi
#idzhangsan
uid=(zhangsan)gid=(zhangsan)groups=(zhangsan)
#idlisi
uid=(lisi)gid=(lisi)groups=(lisi)
#
æ æ³ç»å½ï¼ä¸PAMæå ³
$
$su-zhangsan
Password:
Password:
su:Authenticationfailure
$
设置å¯ç ï¼
#
#cat/etc/passwd|grepzhangsan
zhangsan:x::::/home/zhangsan:/bin/bash
#cat/etc/shadow|grepzhangsan
zhangsan:!!::0::7:::#!!æªè®¾ç½®å¯ç
#
#passwdzhangsan
Changingpasswordforuserzhangsan.
Newpassword:
BADPASSWORD:Thepasswordisshorterthan8characters
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
#
#
#cat/etc/shadow|grepzhangsan
zhangsan:$6$3wxuXomVbQwQcK$oQW6injgldxa2N/Pt4tCPDVRqWRVGw.UNZdxE4R0nhEt8K/3UDKzxap6ReIReEvDpG.GdwjpMiiDh7.f6DJNQ0::0::7:::
#
chageå¯ä»¥æ¥çç¨æ·å¯ç å±æ§
#chage-lzhangsan
Lastpasswordchange:Mar,
Passwordexpires:never
Passwordinactive:never
Accountexpires:never
Minimumnumberofdaysbetweenpasswordchange:0
Maximumnumberofdaysbetweenpasswordchange:
Numberofdaysofwarningbeforepasswordexpires:7
#
å建ç»ï¼ä»å±ç»
#
#groupaddit
#
#
#groupaddsales
#
#
#
#cat/etc/group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x::student
cdrom:x::
mail:x::postfix
man:x::
dialout:x::
floppy:x::
games:x::
tape:x::
video:x::
ftp:x::
lock:x::
audio:x::
users:x::
nobody:x::
dbus:x::
utmp:x::
utempter:x::
input:x::
kvm:x::
render:x::
systemd-journal:x::
systemd-coredump:x::
systemd-resolve:x::
tss:x::
polkitd:x::
rpc:x::
unbound:x::
ssh_keys:x::
sssd:x::
setroubleshoot:x::
rpcuser:x::
insights:x::
cockpit-ws:x::
sshd:x::
chrony:x::
tcpdump:x::
student:x::
printadmin:x::
libstoragemgmt:x::
slocate:x::
postdrop:x::
postfix:x::
apache:x::
zhangsan:x::
lisi:x::
it:x::ç»æåå表
sales:x::
#
#idstudent
uid=(student)gid=(student)groups=(student),(wheel)
#
å°ç¨æ·æ·»å è¿ç»ï¼zhangsan,å å ¥itç»ï¼lisiï¼salesç»
#idstudent
uid=(student)gid=(student)groups=(student),(wheel)
#usermod-aGitzhangsan
#
#
#usermod-aGsaleslisi
#
#
#idzhangsan
uid=(zhangsan)gid=(zhangsan)groups=(zhangsan),(it)
#idlisi
uid=(lisi)gid=(lisi)groups=(lisi),(sales)
#
å é¤ç¨æ·ï¼
#useraddandy
é»è®¤å é¤ï¼ä¿çç¨æ·çæ件ï¼
#
#userdelandy
#
#
#useraddandy#é建andyä¼ä¸ä¸æ ·ï¼uidä¼ä¸å
useradd:warning:thehomedirectoryalreadyexists.
Notcopyinganyfilefromskeldirectoryintoit.
Creatingmailboxfile:Fileexists
#
#useradduser1
#useradduser2
#idandy
uid=(andy)gid=(andy)groups=(andy)
#userdel-rany
userdel:user'any'doesnotexist
#
#userdel-randy#ä¸ä¿çç¨æ·çæ件ã家ç®ï¼é®ç®±æ件ï¼skelæ件é½ä¼
#
#
#idandy
id:âandyâ:nosuchuser
#useraddandy
#idandy
uid=(andy)gid=(andy)groups=(andy)
#
ä»ç»ä¸ç§»é¤ç¨æ·ï¼
#
#idzhangsan
uid=(zhangsan)gid=(zhangsan)groups=(zhangsan),(it)#zhangsan主ç»ï¼itä»å±ç»
#
å½ä»¤ï¼
#gpasswd-dzhangsanit
Removinguserzhangsanfromgroupit
#
#
#idzhangsan
uid=(zhangsan)gid=(zhangsan)groups=(zhangsan)
#
#
#usermod-aGitzhangsan
#
#
#idzhangsan
uid=(zhangsan)gid=(zhangsan)groups=(zhangsan),(it)
#
#
#
#groupszhangsan
zhangsan:zhangsanit
#
ç´æ¥ä¿®æ¹æ件ï¼
#vim/etc/group
#cat/etc/group|grepit:
it:x::
#
å é¤ç»ï¼
#groupaddtest
#
#
#groupdeltest
å建èªå®ä¹ç¨æ·åç»ï¼
å®éªï¼ç¨æ·åmary,æå®ç¨æ·id,家ç®å½/maryhome,ä¸ç¨ç»å½ç³»ç»æè¿°thisismaryuser
#
#useradd-u-d/maryhome-s/sbin/nologin-c"thisismary"mary
#
#idmary
uid=(mary)gid=(mary)groups=(mary)
#cat/etc/passwd|grepmary
mary:x:::thisismary:/maryhome:/sbin/nologin
#
#su-mary
Lastlogin:SunMar::CSTonpts/0
Thisaccountiscurrentlynotavailable.
#
å建èªå®ä¹ç»ï¼æå®ç»id
#groupadd-ggroup1
#cat/etc/group|grepgroup1
group1:x::
#
ç³»ç»ä¹å®¶Linuxæ示Unabletolocatepackage该å¦ä½å¤ç?æä¹åï¼
åå¼å§æ¥è§¦ubuntuçæåå¯è½ä¼æç §ä¸äºå ¥é¨æç« çæ¥éª¤æ´æ¹è½¯ä»¶æºï¼å¯æ¯æ¤æ¶å®è£ 软件çè¯ä¼åºç°unabletolocatepackageçé误ä¾å¦ï¼ä»£ç å¦ä¸ï¼username@ubuntuï¼~$sudoapt-getinstallmysql-servermysql-clientï¼»sudoï¼½passwordforusernameï¼ReadingpackagelistsDoneBuildingdependencytreeReadingstateinformationDoneEï¼Unabletolocatepackagemysql-serverEï¼Unabletolocatepackagemysql-clientusername@ubuntuï¼~$å ¶å®é®é¢åºå¨æ§è¡sudoapt-getinstallä¹åæ´æ¢äºè½¯ä»¶æºï¼ä½æ¯å´å¿äºupdateä¸äºï¼äºæ¯æ§è¡ä¸é¢çå½ä»¤ï¼ä»£ç å¦ä¸ï¼sudoapt-getupdateè¿æ ·ä¸æ¥é®é¢å°±è§£å³äºã
2024-11-18 19:22
2024-11-18 19:21
2024-11-18 18:47
2024-11-18 18:42
2024-11-18 18:08
2024-11-18 17:31
2024-11-18 17:14
2024-11-18 17:13