Skip to content

Instantly share code, notes, and snippets.

@dzlab
Last active April 14, 2016 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dzlab/91d66f30341fb361994e to your computer and use it in GitHub Desktop.
Save dzlab/91d66f30341fb361994e to your computer and use it in GitHub Desktop.
A collection of commands
# Virtualbox: Mount the shared folder
sudo mount -t vboxsf temp Shared
# process listening on a port (e.g. 5000)
lsof -i :5000 # find the process
lsof -i :80 # find the program running on a port
kill -9 PID # kill process
sudo netstat -lpn |grep :5000
netstat -tan | grep ':80 ' | awk '{print $6}' | sort | uniq -c # view list of connections and their states
ss -rota | less # list all connections and timers
find / -name filename # search for a file
find . -type f | wc -l # count files in current and subsequent folders
find . -name "*.gz" | xargs -J {} mv {} /tmp/ # moving .gz files into /tmp/
grep -R "test" /var/x/ # search a string in folder recursively
grep -rnw '/path/to/somewhere/' -e "pattern" # search a string in folder and gives line number in file
cmd >>file.txt 2>&1 # forward stdout and stderr to a file
sudo passwd root # reset root password
sudo -H -u otheruser bash -c 'echo "I am $USER, with uid $UID"' # run a command with another user
for f in *.txt; do echo "Processing $f"; done # loop over files and do some work
jar tf my-fat-jar-file.jar | grep filename # print the content of a jar and look for a given file
# create certificate for https server
openssl genrsa -out server.key 2048
openssl req -new -x509 -key server.key -out server.pem -days 3650
# write something to a file
cat << EOF > file
cd "$HOME"
echo "$PWD" # echo the current path
EOF
< file tee file-{001..100} # repeat a file a hundread time
cat file-* > file # copy the content of multiple files into one
echo "hello world" >> my_file.txt # append a line of text to a file by using the >> operator
sudo sh -c 'echo "hello world" >> my_file.txt' # append a line of text to a file as root
split -l line_count file_name # split a file into multiple pieces by line_count lines
ln -s /path/to/file /path/to/symlink # create a symbolic link
# create executable jar
echo Main-Class: Craps > manifest.txt
jar cfm filename.jar manifest.txt Classname.class ...
# windows save some space
powercfg -h off
# hadoop
hdfs dfsadmin -report
yarn logs --applicationId <application> --containerId <container> -nodeAddress hadoop-server-2:49030
yarn application -kill <application>
# Administration commands:
sudo apt-get install htop # cpu/mem usage
egrep --color 'Mem|Cache|Swap' /proc/meminfo # available mem
#Checking for disk space on HDFS:
hdfs dfs -du -h /
hadoop dfsadmin -report
#Making the NodeManager leaves its safe mode:
hdfs dfsadmin -safemode leave
# vagrant
vagrant init
vagrant box add hashicorp/precise32 #Vagrantfile config.vm.box = "hashicorp/precise32"
vagrant up --provider virtualbox
# when vitual box guest os is missing
vagrant plugin install vagrant-vbguest
vagrant vbguest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment