install vagrant and VMBox on your local machine
vagrant init ubuntu/trusty64 installs a ubuntu (64-bit) trusty tahr VMBoxvagrant up to boot up a linux in the terminal CLIvagrant ssh to log-in to this servervagrant status: shows VMBox statusvagrant suspend: puts VMBox to sleep/hibernatevagrant up: boots VMBoxvagrant ssh: logs into VMBox as the default vagrant uservagrant halt: shuts down the VMBoxvagrant destroy: resets the VMBox to fresh install (of linux, in this case)ls
$PATH
ls like /bin/ls to use the ls command$PATH variableecho $PATH outputs /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/gamesls and such commands are input at the CLI,
$PATH variable are scanned to find a match and runcat /etc/apt/sources.listapt-getman apt-get to learn moreupgrades distribution etc.
sudo apt-get autoremove: remove packages that were automatically installed to satisfy dependencies for other packages and are now
no longer needed
install finger using sudo apt-get install finger
python3 --version: view version of currently installed python3sudo apt-get updatesources.list file in /etcsudo apt-get upgrade
upgrade is relatively harmlesssudo prefixsudo command typically simulates root user privileges
sudo enabled by default
sudo to server accounts
su command cna be used to switch the entire context to root superuser
/etc/passwd
cat /etc/passwd displays this infousername:encrypted-passwd:userID:groupID:user-desc:home-dir:default-shellroot user rules:
00/root/bin/bashroot
sudo abilitiessudo adduser studentssh student@127.0.0.1 -p 2222
ssh: command to connect through SSH remotelystudent@127.0.0.1: user@ip-address
127.0.0.1: localhost-p 2222: vagrant’s port for incoming connectionssudo users:
sudo cat /etc/sudoerssudo ls /etc/sudoers.dsudo privileges to the newly created ‘student’ user
student user should be just like vagrant usersudo cp /etc/sudoers.d/vagrant /etc/sudoers.d/studentsudo nano /etc/sudoers.d/student
vagrant to student in filels -al: table of everything in a dir with associated details
drwxr-xr-x’, ‘-rw-r--r--’d or file -rwx-: that permission in not granted for that triplet entitydrwxr-xr-x == ‘d’ + ‘rwx’ + ‘r-x’ + ‘r-x’,
d
rwx
r-x
-rw-r--r-- == ‘-’ + ‘rw-’ + ‘r--’ + ‘r--’
-: indicates it’s a file (not a dir)rw-: owner can read and write, but not executer--: group and everyone can only read, nothing elsels -al) indicate owner and group respectively
ls -al in parent dir of the file/dir to see it’s owner and grouproot is the owner for core linux files
w (write) permissions.ssh folder, for instance:
chmod 644 ~/.sshrw-r--r--r == 4 (read)w == 2 (write)x == 1 (execute)rwx == [4 + 2 + 1] == 7r-x == [4 + 0 + 1] == 5r-- == [4 + 0 + 0] == 4chmod: change the mode of file/dir (mode == permission mode)
chmod 655 filename.extchown: change owner
chown root filename.extchgrp: change group
chgrp vagrant filename.ext$ ssh-keygen on your local machine
~/.ssh/.pub public key (goes on the server)touch .ssh/authorized_keysnano
nano .ssh/authorized_keys.pub file generated by ssh-keygen on the local machineauthorized_keys on the server
nanochmod 644 .ssh/authorized_keyschmod 700 .sshchmod command with appropriate parameters sets/changes mode of file/folderssh student@localhost -p 2222 -i ~/.ssh/linuxCourse/etc/ssh/sshd_config with nanoPasswordAuthentication and change following text to nossh: sudo service ssh restart
port 80port 443port 22port 21port 110port 25ufw is the preinstalled firewall in ubuntuufw in ubuntu is turned off by default
sudo ufw status : provides status of firewallsudo ufw default deny incomingsudo ufw default allow outgoingsudo ufw allow shhvagrant ssh
sudo ufw allow 2222/tcpsudo ufw allow wwwsudo ufw enablesudo ufw status47% of today’s web-servers are driven by apache
sudo apt-get install apache2sudo service apache2 restartlocalhost:8080 on your local machine’s browser
sudo apt-get install libapache2-mod-wsgiWSGIScriptAlias / /var/www/html/myapp.wsgi to the end of the <VirtualHost *:80>...</VirtualHost> block in file /etc/apache2/sites-enabled/000-default.confadduser command under linux users section abovessh-keygen process abovevscode for ease of use.pub file key from the local machine into the authorized_keys file
.ssh folderin the configuration file, add the following block of code
Host <output of hostname command in vagrant box CLI>
User <Vagrant box's new-user's name>
HostName localhost
Port 2222
IdentityFile ~/.ssh/vscode
chmod and chown to enable file edits/var/www/html folder for instance has root ownership by default