My Common Commands

This article just is used to document some of my common commands:

Linux

1
2
3
4
5
6
7
8
9
10
ssh usn@hostname

# make a new folder
mkdir foldername

# delete folder and it's files
rm -rf foldername

# Change the file mode bits of each given file according to mode
chmod 777

docker(docker-compose)

1
2
3
4
5
6
7
8
9
10
11
12
13
docker ps -a
docker rm container

docker image ls
docker rmi imageID

docker-compose up [-d]
docker-compose down

docker exec -it container bash

docker cp mycontainer:/opt/testnew/file.txt /opt/test/
docker cp /opt/test/file.txt mycontainer:/opt/testnew/

nginx

nginx port forwarding

1
2
3
4
5
6
7
8
9
10
11
12
server {
listen 80;
server_name domainname.com;
access_log /path/name.log;
error_log /path/name.error;

location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://domainname.com:port;
}
}

Screen

1
2
3
4
5
6
7
8
# Starting Named Session
screen -S session_name

# Detach from Linux Screen Session
Ctrl+a d

# Reattach to a Linux Screen
screen -r session

Git

1
2
3
4
5
6
7
8
9
# checkout a new branch
git checkout -b|-B <new-branch> [<start-point>]

# push to remote
git push origin local_branch:remote_branch

# delete the remote branch
git push origin :remote_branch
git push origin --delete remote_branch