# Linux

# Commands

Command Description
uname -a To find out 32 / 64 Bit Operating System
rm -r /path Delete Files or Directory use -r for recorsive
tar xzvf <file Name> Untar and decompress the file
ps aux | grep mongo check mongodb is working or not
tail ~/mongo/logs/mongodb.log print files from bottom
mv foo bar rename folder foo to bar

# Creating Vitual Host

# Python Webserver

Python 2

python -m SimpleHTTPServer 8080
1

Python 3

python -m http.server 8080
1

# PHP Webserver

php -S localhost:8080
1

# Apache (Virtual Host)

# Step
1 Download repository from https://github.com/RoverWire/virtualhost (opens new window)
2 Apply permission to execute: $ chmod +x /path/to/virtualhost.sh

# Optional

if you want to use the script globally, then you need to copy the file to your /usr/local/bin directory, is better if you copy it without the .sh extension

sudo cp /path/to/virtualhost.sh /usr/local/bin/virtualhost|
1

# Basic Syntax

sudo sh /path/to/virtualhost.sh [create | delete][domain] [optional host_dir]
1

Example to create a new virtual host:

sudo virtualhost create mysite.dev
1

to create a new virtual host with custom directory name:

sudo virtualhost create anothersite.dev my_dir
1

to delete a virtual host

sudo virtualhost delete mysite.dev
1

to delete a virtual host with custom directory name:

sudo virtualhost delete anothersite.dev my_dir
1

# Creating Shell Script

create a file save it path/xxx.sh
chomod +x path/xxx.sh
execute path/./xxx/sh

sudo cp path/xxx.sh /usr/local/bin/xxx
execute xxx
1
2
3
4
5
6

# robot.txt

https://davidwalsh.name/robots-txt (opens new window)

User-agent: *
Disallow: /
1
2

# Scripts

ftp to google drive : http://olivermarshall.net/how-to-upload-a-file-to-google-drive-from-the-command-line/ (opens new window)

# SSH

ssh -p <port> username@example.com
1

# scp

# from local to remote
cp notice.doc root@domain:/home/jones

# from remote to local
scp root@domain:/home/jones/letter.doc .
1
2
3
4
5

# Nohup

nohup node my_app.js &
1

# Create User

adduser <username>

command Description
adduser <user> Create User
id <user> Check user is created
usermod -aG sudo <user> Add sudo permission to user
id <user> Verify group is added
su - <user> Change login
whoami check login
mkdir ~/.ssh Create folder for ssh keys
chomod 700 ~/.shh Change permission not accessible to other user
chomod 600 ~/.shh Remove writing permission
sudo nano /etc/ssh/ssh_config Open ssh_config file to disable root login and password
PermitRootLogin no Change from yes to no
PasswordAuthentication no remove # and change yes to no
sudo systemctl reload sshd reload the configuration
sudo ufw allow OpenSSH Firewall to open ssh port
sudo ufw allow http Firewall to open http port
sudo ufw allow https Firewall to open https port
sudo ufw enable Allow the ports to be enabled
sudo ufw statsu Will show Firewall status
sudo apt-get git Install git

# zsh

# Alias

alias wr="cd ~/www"
alias wiki="cd ~/www/cloudapmc.com/wiki.tss.net.in"
alias family="cd ~/www/cloudapmc.com/nirgun.co.in"
alias ec="cd ~/www/cloudapmc.com/store.cloudapmc.com"
alias api="cd ~/www/cloudapmc.com/api.cloudapmc.com"
# alias ls -l="ls -lh"
1
2
3
4
5
6
Last Updated: 29/12/2021 9:58:12 am