亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1760 | 回復: 2
打印 上一主題 下一主題

[系統(tǒng)管理] fuser使用中的疑問 [復制鏈接]

論壇徽章:
5
程序設計版塊每日發(fā)帖之星
日期:2016-04-15 06:20:00每日論壇發(fā)貼之星
日期:2016-04-15 06:20:0015-16賽季CBA聯(lián)賽之八一
日期:2016-07-08 09:20:28操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-08-03 06:20:002016科比退役紀念章
日期:2016-10-30 13:59:12
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2016-07-31 14:30 |只看該作者 |倒序瀏覽
當使用fuser的命令時,我使用:
fuser -mvk /mnt

1.如果/mnt是被掛載的目錄,那么執(zhí)行上面的命令可以kill掉所有的跟/mnt相關的進程
2.如果/mnt不是被掛載的目錄,那么執(zhí)行上面的命令就會把系統(tǒng)的所有進程都kill掉,如果有圖形界面的話,就會退回到登錄界面。

請問為了確保fuser能夠殺掉掛載目錄的相關進程,而同時如果另一個目錄沒有掛載,當使用fuser的時候不會對系統(tǒng)產(chǎn)生任何影響,是否應該使用 fuser -kv 目錄名 ?或者fuser后面跟其它什么參數(shù)?

論壇徽章:
9
操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-01-08 06:20:00操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-01-28 06:20:0015-16賽季CBA聯(lián)賽之四川
日期:2016-05-17 17:50:32操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-08-01 06:20:0015-16賽季CBA聯(lián)賽之廣東
日期:2016-08-01 16:01:57操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-08-04 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-08-07 06:20:00操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-08-07 06:20:0015-16賽季CBA聯(lián)賽之福建
日期:2017-03-07 17:14:27
2 [報告]
發(fā)表于 2016-08-01 09:39 |只看該作者
fuser -v    再根據(jù)實際情況殺你要殺的PID

求職 : Linux運維
論壇徽章:
203
拜羊年徽章
日期:2015-03-03 16:15:432015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:092015小元宵徽章
日期:2015-03-06 15:58:182015年亞洲杯之約旦
日期:2015-04-05 20:08:292015年亞洲杯之澳大利亞
日期:2015-04-09 09:25:552015年亞洲杯之約旦
日期:2015-04-10 17:34:102015年亞洲杯之巴勒斯坦
日期:2015-04-10 17:35:342015年亞洲杯之日本
日期:2015-04-16 16:28:552015年亞洲杯紀念徽章
日期:2015-04-27 23:29:17操作系統(tǒng)版塊每日發(fā)帖之星
日期:2015-06-06 22:20:00操作系統(tǒng)版塊每日發(fā)帖之星
日期:2015-06-09 22:20:00
3 [報告]
發(fā)表于 2016-08-02 00:12 |只看該作者
fuser命令學習
fuser:使用文件或者套節(jié)字來表示識別進程。我常用的他的兩個功能:查看我需要的進程和我要殺死我查到的進程。
比如當你想umount光驅(qū)的時候,結果系統(tǒng)提示你設備正在使用或者正忙,可是你又找不到到底誰使用了他。這個時候fuser可派上用場了。
[root@lancy sbin]# eject
umount: /media/cdrom: device is busy
umount: /media/cdrom: device is busy
eject: unmount of `/media/cdrom' failed
[root@lancy sbin]# fuser /mnt/cdrom
/mnt/cdrom: 4561c 5382c
[root@lancy sbin]# ps -ef |egrep '(4561|5382)' |grep -v grep
root 4561 4227 0 20:13 pts/1 00:00:00 bash
root 5382 4561 0 21:42 pts/1 00:00:00 vim Autorun.inf
示例中,我想彈出光驅(qū),系統(tǒng)告訴我設備忙著,于是采用fuser命令,參數(shù)是你文件或scoket,fuser將查出那些使用了他。
4561c,5382c表示目前用兩個進程在占用著/mnt/cdrom,分別是4561,5382,進程ID后的字母表示占用資源的方式,有下面幾種表示:
c 當前路徑(current directory.)我的理解是表示這個資源的占用是以文件目錄方式,也就是進進入了需要釋放的資源的路徑,這是最常用的資源占用方式。
e 正在運行可執(zhí)行文件(executable being run.),比如運行了光盤上的某個程序
f 打開文件( open file),缺省模式下f忽略。所以上面的例子中,雖然是開打了光盤上的Autorun.inf文件,但是給出的標識是c,而不是f。
r root目錄(root directory).沒有明白什么意思,難道是說進入了/root這個特定目錄?
m mmap文件或者共享庫( mmap’ed file or shared library).這應該是說某個進程使用了你要釋放的資源的某個共享文件。
其他字母見文章最后的表格

在查找的同時,你還可定指定一些參數(shù),比如
-k 殺死這些正在訪問這些文件的進程。除非使用-signal修改信號,否則將發(fā)送SIGKILL信號。
-i 交互模式
-l 列出所有已知的信號名稱。
-n 空間,選擇不同的名字空間,可是file,udp,tcp。默認是file,也就是文件。
-signal 指定發(fā)送的信號,而不是缺省的SIGKILL
-4 僅查詢IPV4套接字
-6 僅查詢IPV6套接字
- 重置所有的選項,將信息設回SIGKILL
再看下面的例子
[root@lancy sbin]# fuser -l
HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM
STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH IO PWR SYS
UNUSED
現(xiàn)在我們試試fuser -k的威力:
[root@lancy sbin]# fuser -k /mnt/cdrom
/mnt/cdrom: 4561c 5382c
kill 5382: 沒有那個進程
No automatic removal. Please use umount /media/cdrom

[root@lancy sbin]# eject

套節(jié)字方式的使用:
[root@lancy sbin]# fuser -4 -n tcp 3306
here: 3306
3306/tcp: 5595

[root@lancy sbin]# ps -ef |grep 5595 |grep -v grep
mysql 5595 5563 0 22:24 pts/0 00:00:00 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/var/lib/mysql/mysql.sock

[root@lancy sbin]# fuser -4 -n tcp 80
here: 80
80/tcp: 5685 5688 5689 5690 5691 5692 5693 5694 5695

List Open Files: lsof and fuser
The function of these commands is very similar. The goal is to determine what processes have certain files open. lsof is freeware and thus freely compilable under all Unixes. It is available by default under Linux only.
The main difference between lsof and fuser is that lsof takes both files/filesystems and PIDs as arguments whereas fuser only accepts files/filesystems.
lsof:
lsof stands for list open files. It lists information about files that are currently open by processes.
In the absence of any options, lsof lists all open files belonging to all active processes
To list all open files for login name ``abe'', or user ID 1234 you would use the -u option. To list files being used by process 456, process 123, or process 789, you would use the -p flag. Putting these criteria together, we would have a command that looks like this:
lsof -p 456,123,789 -u 1234,abe
The command to list all open files on device /dev/hd4, would look like this:
lsof /dev/hd4
To find the process that has /u/abe/foo open, use:
lsof /u/abe/foo
fuser:
fuser is more widely available (under AIX, HP-UX, IRIX, Linux, Solaris, Tru64 UNIX, and others) and can only be run as root. It displays the process ID numbers of processes using the specified files or file systems. In the default display mode, each file name is followed by a letter denoting the type of access (these codes differ from vendor to vendor):
a        if the process is using the file as its trace file in /proc (IRIX)
c        if the process is using the file as its current directory
e        if the process is using the file as the executable being run
f        if the process is using the file as an open file (Linux)
m        if the process is using the file as a mmaped or shared lib (Linux)
o        if the process is using the file as an open file (IRIX, Solaris, Tru64 UNIX))
p        if the process is using the file as the parent of its current directory (Tru64 UNIX)
r        if the process is using the file as root directory
s        if the process is using the file as a shared lib (AIX)
t        if the process is using the file as its text file (Solaris)
y        if the process is using the file as its controlling terminal (IRIX)
Here is an example of fuser running under Linux:
linux# /usr/sbin/fuser /
/: 1r 1c 2r 2c 3r 3c 4r 4c
252r 252c 275r 275c 286r 286c 300r 314r 328r 328c 342r
342c 356r 356c 374r 374c 385r 385c 396r 396c 411r 411c
412r 412c 413r 413c 414r 414c 415r 415c 416r 416c 417r
417c 418r 418c 419r 419c 420r 420c 455r 470r 470c 485r
485c 500r 500c 538r 538c 539r 539c 540r 540c 541r 541c
542r 542c 543r 543c 544r 544c 546r 546c 548r 548c 551r
551c 556r 569r 591r 597r 610r 612r 614r 614c 618r 626r
628r 636r 646r 7090r 7090c 7092r 7243r 7288r 7288c 7290r 7303r


fuser 和 lsof 可以用于系統(tǒng)安全檢查。
用fuser查看哪些用戶和進程在某些地方作什么:
fuser -cu /root 簡略顯示

fuser -muv /mnt3 分列顯示
root@steven ~]# fuser -muv !$
fuser -muv /root
                     用戶     進程號 權限   命令
/root:               root          1 .rce. (root)init
                     root          2 .rc.. (root)kthreadd
                     root          3 .rc.. (root)migration/0
                     root          4 .rc.. (root)ksoftirqd/0
                     root          5 .rc.. (root)stopper/0
   
                     root       1742 .rc.. (root)flush-8:16
                     root       1743 .rc.. (root)flush-8:0
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP