Last active
September 25, 2015 19:38
-
-
Save mmiliaus/973506 to your computer and use it in GitHub Desktop.
Pro Linux System Administration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=users and groups | |
# add user into 'admin' group, only users in 'admin' group can use 'sudo' | |
sudo usermod -G admin username | |
# useradd defaults | |
/etc/default/useradd | |
# check to what groups user belongs to | |
id username | |
# ubuntu | |
adduser, addgroup | |
# change password | |
passwd | |
# set password expirations for 30 days | |
sudo chage -M 30 ataylor | |
# disable user | |
sudo usermod --expiredate 1 | |
# copy contents of the folder to another folder | |
sudo cp -R * /var/lib/tomcat6/lib/ | |
# login as another user | |
su {username} | |
#check who is listening on particular port | |
netstat -lnp | grep :80 | |
# make vpn connection last long | |
sudo vpnc --dpd-idle 0 | |
# find all files modified 90 min ago | |
find . -mmin -90 | |
# find all files in particular directory by some extension | |
# and add execution permission for all users for those files | |
find ./application/default/cmd/ -name "*.php" | xargs chmod a+x | |
# imitate slow connection, i.e. 2 sec delay between each pocket sent | |
sudo tc qdisc change dev eth0 root netem delay 2000ms | |
# edit crontab with vim | |
env EDITOR=vim crontab -e | |
# check which files are opened by particular process | |
/usr/sbin/lsof -p 9537 | |
# scan local network | |
nmap -sP 192.168.1.0/24 | |
# restore MySQL database from raw backup | |
cp -R /old_file_system/var/lib/mysql/* /var/lib/mysql | |
# rsync from remote through ssh | |
rsync -avz -e ssh remoteuser@remotehost:/remote/dir /this/dir/ | |
## single file | |
rsync -chavzP --stats user@remote.host:/file/path.json /file/path.json | |
# get total occupied disk space by the directory | |
du -ch /path/to/directory | grep total | |
# inspect disk usage | |
df -h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment