Skip to content

Instantly share code, notes, and snippets.

@jlyon
Last active December 17, 2015 18:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlyon/5652313 to your computer and use it in GitHub Desktop.
Save jlyon/5652313 to your computer and use it in GitHub Desktop.
ubuntu basic command line(sed, scp, df, rsync, users)
# create a user with a home dir, add to group
useradd -m -d/home/if.jeff -Gwww-data -s/bin/bash if.jeff
# tar
tar cvzf foo.tgz foo
tar xvzf foo.tgz
# zip
zip foo.zip foo
unzip foo.gz
# gz
gunzip foo.gz
gzip filename.txt
# bz2
bunzip2 file.bz2
# disk free
df -h
# free memory
free -m
# unblock from firewall
nano /etc/csf/csf.deny # find ip and comment out
csf -r
# recursively download a dir via ftp
wget -r ftp://user:pass@server.com/
# transfer dirs over ssh
scp (see tutorials)
# show processes, kill a specific process
ps aux
kill <pid>
# sed, search and replace
# specific line
sed -n '20,40p' file_name
# directory sizes
du -h --max-depth=1 . | sort -n -r
# find big files
find /etc -size +100k -size -150k
# search and replace over dirs
sed -r 's/thisip/thatip/g'
find ./ -type f -exec sed -i 's/apple/orange/g' {} \;
# fix locales
sudo dpkg-reconfigure locales
# rsync (from remote server)
rsync -avz thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp
#some permission stuff from https://wiki.archlinux.org/index.php/Chmod
# hit directories (recursively) in a folder "/" after directory is IMPORTANT
find directory/ -type d -print0 | xargs -0 chmod 755
# hit files (recursively) in a folder "/" after directory is IMPORTANT
find directory/ -type f -print0 | xargs -0 chmod 644
# I adapted it to this for my task of replacing IP addresses. The first set of numbers is the old one (don’t delete the backslashes) and the second set is the new one.
find . -name '[^.]*' | xargs perl -pi -e 's/192\.168\.1\.3/192\.168\.0\.3/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment