- Run a process detached to the current terminal:
nohup my_command &
- Get the exit code of the latest runned command:
echo $?
- Run the last command as
root(source):sudo !!
- Show the user under which I’m currently logged in:
whoami
- List cron jobs of the current user:
crontab -l
- If you have the following error:
-bash: ./myscript.sh: /bin/bash^M: bad interpreter: No such file or directory
Then the fix consist of removing the bad characters:
sed -i 's/\r//' ./myscript.sh
- Free up some memory by clearing RAM caches (source):
sync ; echo 3 > /proc/sys/vm/drop_caches
- Display which distro is running the system (source):
lsb_release -a
or
cat /etc/lsb-release
- List of most used commands:
history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head - Disable a service on Debian/Ubuntu, then re-enable it:
update-rc.d my-service-name remove update-rc.d my-service-name defaults
- Same thing as above but on a RedHat-like system:
chkconfig sshd --del chkconfig sshd --add
Another tip: if you have
screenandrettyon your computer, you can move an application to a screen by usingscreen retty $PID. I like it better thannohupbecause you can keep the interactivity with the process.@djib: you’re absolutely right !
screenis a really good tool. To be honest playing with it is on my TODO list for what… 5 years ? It’s just that because I knownohupexists I don’t have any strong incensitive to learnscreen…Pingback: All my command lines | Kevin Deldycke