added ppu and ppn
This commit is contained in:
@@ -49,6 +49,8 @@ ku Kill process owned by users in parameter
|
|||||||
mcd Create a directory and go inside
|
mcd Create a directory and go inside
|
||||||
meteo Display curent weather forecast for the configured city
|
meteo Display curent weather forecast for the configured city
|
||||||
ppg Display process matching the given parameter
|
ppg Display process matching the given parameter
|
||||||
|
ppn Display process matching the exact process name given in parameter
|
||||||
|
ppu Display processes owned by the given user
|
||||||
rain Let the rain fall
|
rain Let the rain fall
|
||||||
rmhost Remove host (IP and/or DNS name) for current known_host
|
rmhost Remove host (IP and/or DNS name) for current known_host
|
||||||
rmspc Remove spaces from all the files in working directory
|
rmspc Remove spaces from all the files in working directory
|
||||||
|
|||||||
@@ -43,6 +43,39 @@ ppg()
|
|||||||
}
|
}
|
||||||
export -f ppg
|
export -f ppg
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# List processes owned by a specific user
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
ppu()
|
||||||
|
{
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
disp E "Usage: ppu <username>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -u lists processes for a specific user
|
||||||
|
# -o provides a clean, standard output format
|
||||||
|
ps -u "$1" -o pid,user,%cpu,%mem,start,time,command
|
||||||
|
}
|
||||||
|
export -f ppu
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# List processes by exact command name (no path/parameters)
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
ppn()
|
||||||
|
{
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
disp E "Usage: ppn <command_name>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -e: select all processes
|
||||||
|
# -o: specify custom output columns (PID and Command name)
|
||||||
|
# grep -w: ensures exact word matching so 'bash' doesn't match 'dbash'
|
||||||
|
ps -eo pid,comm | grep -w "$1"
|
||||||
|
}
|
||||||
|
export -f ppn
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Get PID list of the given process name
|
# Get PID list of the given process name
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@@ -63,7 +96,7 @@ gpid()
|
|||||||
export -f gpid
|
export -f gpid
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Kill all processes owned by the given users
|
# Kill all processes owned by the given users (kill user)
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
ku()
|
ku()
|
||||||
{
|
{
|
||||||
@@ -74,7 +107,7 @@ ku()
|
|||||||
export -f ku
|
export -f ku
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Kill all children of a process then the process
|
# Kill all children of a process then the process (kill tree)
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
kt()
|
kt()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user