Last active
March 12, 2018 16:34
-
-
Save mallond/9887e7601979e0b76424da48ca56ea5f to your computer and use it in GitHub Desktop.
Got Linux - shell commands
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
########## | |
# File Transfer | |
########## | |
# Copy files through ssh | |
scp deployer@fake-server:/var/log/mongodb/mongod.log.2.gz /Users/name/Documents/temp/logs/ | |
# Copy a file from your workstation to a server behind a bastion host | |
scp -oProxyCommand="ssh -AW %h:%p bastion_user@bastion_ip" file_destination user@destination_IP:/path | |
scp -oProxyCommand="ssh -AW %h:%p ubuntu@bastion-production" dockerengine_install.sh ubuntu@fake-server:/home/ubuntu/ | |
## Speed up secure file copying (scp) by tarring files before copying them to another server. | |
# Local > Remote | |
tar cvzf - -C /Users/nickivons/Documents/temp/dbpath/ . | ssh deployer@fake-server tar xzvf - -C /home/deployer/backups | |
# Remote > Local | |
ssh deployer@fake-server "tar czvf - -C /var/lib/mongodb/ ." | tar xzvf - -C /Users/user/Documents/temp/newDbpath | |
# Remote > Remote | |
ssh deployer@fake-server "tar czvf - -C /var/lib/mongodb/ ." | pv | ssh deployer@fake-server-2 tar xzvf - -C /home/deployer/backups | |
# Rsync to copy very large files | |
rsync -vh -rlptD --chmod=g+w --info=progress2 -e ssh deployer@fake-server:/var/lib/mongodb/ /var/lib/mongodb-bear | |
########## | |
# Analyzing File Systems | |
########## | |
#See size of directories | |
du -sh * | |
#See space on server | |
df -h | |
#See space on individual directories | |
du -h --max-depth=1 | |
du -h --exclude=./home/user1/nas | grep -E \[0-9]G | |
#See file sizes in GB | |
ls -lh | |
# Find top directories | |
du -a / | sort -n -r | head -n 5 | |
########## | |
# Process Management | |
########## | |
# See if mongod (or any process) is running | |
ps -deaf | grep mongod | |
ps -aux | grep mongod | |
# Get details about a process id | |
ps -Fp $pid | |
# See what process is running on port 8000 | |
lsof -t -i :8000 | |
########## | |
# Server Administration | |
########## | |
# show env variables | |
printenv | |
# see what ports are open | |
netstat -plnt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment