新聞中心
linux 命令行下通過(guò)id號(hào)查詢用戶名及主目錄
awk -F: '{if($3==0){print $1}}' /etc/passwd
創(chuàng)新互聯(lián)網(wǎng)站建設(shè)提供從項(xiàng)目策劃、軟件開發(fā),軟件安全維護(hù)、網(wǎng)站優(yōu)化(SEO)、網(wǎng)站分析、效果評(píng)估等整套的建站服務(wù),主營(yíng)業(yè)務(wù)為成都網(wǎng)站制作、成都做網(wǎng)站,app軟件定制開發(fā)以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。創(chuàng)新互聯(lián)深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
其中 0 為你想查詢的用戶id
如何在Windows和Linux下獲取當(dāng)前線程的ID號(hào)
Linux下獲取當(dāng)前線程ID號(hào)函數(shù):
pthread_t pthread_self();
返回:當(dāng)前線程的ID號(hào)
pthread_t 數(shù)據(jù)類型的定義如下:
typedef unsigned long int pthread_t;
sizeof(pthread_t) = 4,4個(gè)字節(jié)的整數(shù)。
Windows下獲取當(dāng)前線程ID號(hào)的函數(shù):
DWORD GetCurrentThreadId();
返回值:當(dāng)前線程的ID號(hào)
DWORD數(shù)據(jù)類型定義:
typedef unsigned long DWORD;
在Windows下pthread-win庫(kù)的pthread_t定義如下:
typedef struct {
void * p; /*Pointer to actual object */
unsigned int x; /*Extra information - reuse count etc */
} ptw32_handle_t;
typedef ptw32_handle_t pthread_t;
與Linux的thread_t不一樣,它是一個(gè)結(jié)構(gòu),不是一個(gè)整數(shù)值
在Windows和Linux下可用的獲取線程ID號(hào)的內(nèi)聯(lián)函數(shù)如下:
#ifdef WIN32
#include windows.h
#else
#include pthread.h
#endif
inline unsigned int PthreadSelf()
{
#ifdef WIN32
return::GetCurrentThreadId();
#else
returnthread_self();
#endif
}
linux ps命令顯示最大的進(jìn)程id號(hào)
我的Fedora
Core是用下面的命令
ps
h
|
awk
$1}'
|
sort
-nr
|
head
-1
(1)
ps
h不顯示“USER
PID
%CPU
%MEM
VSZ
RSS
TTY
STAT
START
TIME
COMMAND”信息
(2)用awk輸出你的PID列
(3)逆序排列
(4)輸出第一行
你的應(yīng)該可以用類似的方法實(shí)現(xiàn)
你可以試試
ps
auxh|
awk
$2}'
|
sort
-nr
|
head
-1
新聞名稱:linux命令行獲取id linux獲取所有用戶
網(wǎng)站網(wǎng)址:http://ef60e0e.cn/article/ddjegpj.html