- When you run a command on the shell if first forks the process and then execs the command
exec
does not forkps f
shows processes as a tree- a child inherits stdin, stdout and stderr
- Ctrl + z suspends the process
jobs
shows jobs runningfg
brings a process to the foreground (if there is only one)fg %3
brings process no. 3 to the foreground- T means stopped, S means sleep
-
- is last job and - is second to last
ps ax
show all processeskill -l
list of signalskill -15
sigtermkill
sigterm, kills gracefullykill -2
sigintkill -1
sighupkill -9
sigkill, brute force kill
# ss -lpntu
# ss -plunt
or
# lsof -i -P -n
su -s /bin/bash -c '/path/to/your/script' testuser
mountpoint /dev
$ stat -c "%a %n" *
$ date -d @1363292159.532
Thu Mar 14 21:15:59 CET 2013
$ find /sys -xdev -inum 30
/sys/devices/system/cpu/online
find . \( $COND1 -exec $CMD1 \) , \( $COND2 -exec $CMD2 \)
- For XFS systems, on
/etc/default/grub
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX rootflags=uquota,pquota"
echo "test log1" >> /proc/$PID/fd/1
- files -> /etc/hosts
- myhostname, mymachines -> systemd-container
- resolve -> systemd-resolved
- dns -> /etc/resolv.conf
https://news.ycombinator.com/item?id=19439722
- Disable cores:
echo 0 > /sys/devices/system/cpu/cpu<n>/online
- Check frequency range
cpupower frequency-info
- Adjust frequencies and governor
# set governor
cpupower frequency-set -g <governor>
# max freq
cpupower frequency-set -u <freq>
# min freq
cpupower frequency-set -d <freq>
[Unit]
Description=Powertop tunings
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/powertop --auto-tune
[Install]
WantedBy=multi-user.target
runuser -s /bin/bash <user> -c "$*"
setpriv
is better for dropping privileges since it doesn't use PAM and it doesn't spawn an extra process
setpriv --no-new-privs --reuid=1000 --regid=1000 --init-groups --reset-env "$@"
# default for new files
setfacl -d -R -m u:theUsersName:rwx
# actually set permission
setfacl -R -m u:theUsersName:rwx
( cd "$src" && tar -cf - .) | (cd "$dst" && tar xvf - )
# show all rules
ip rule list
# create table
echo 200 custom >> /etc/iproute2/rt_tables
# from ip
ip rule add from <source address> lookup <table name>
# from interface
ip rule add iif <interface> table isp2 priority 1000
# add default gw
ip route add default via 192.168.30.1 dev eth1 table custom
# show table 1
ip route show table 1