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/games
ls
and such commands are input at the CLI,
$PATH
variable are scanned to find a match and runcat /etc/apt/sources.list
apt-get
man 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 update
sources.list
file in /etc
sudo 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-shell
root
user rules:
0
0
/root
/bin/bash
root
sudo
abilitiessudo adduser student
ssh 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/sudoers
sudo ls /etc/sudoers.d
sudo
privileges to the newly created ‘student’ user
student
user should be just like vagrant
usersudo cp /etc/sudoers.d/vagrant /etc/sudoers.d/student
sudo 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 -
r
w
x
-
: 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 ~/.ssh
rw-
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.ext
chown
: change owner
chown root filename.ext
chgrp
: change group
chgrp vagrant filename.ext
$ ssh-keygen
on your local machine
~/.ssh/
.pub
public key (goes on the server)touch .ssh/authorized_keys
nano
nano .ssh/authorized_keys
.pub
file generated by ssh-keygen
on the local machineauthorized_keys
on the server
nano
chmod 644 .ssh/authorized_keys
chmod 700 .ssh
chmod
command with appropriate parameters sets/changes mode of file/folderssh student@localhost -p 2222 -i ~/.ssh/linuxCourse
/etc/ssh/sshd_config
with nano
PasswordAuthentication
and change following text to no
ssh
: sudo service ssh restart
port 80
port 443
port 22
port 21
port 110
port 25
ufw
is the preinstalled firewall in ubuntuufw
in ubuntu is turned off by default
sudo ufw status
: provides status of firewallsudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow shh
vagrant ssh
sudo ufw allow 2222/tcp
sudo ufw allow www
sudo ufw enable
sudo ufw status
47% of today’s web-servers are driven by apache
sudo apt-get install apache2
sudo service apache2 restart
localhost:8080
on your local machine’s browser
sudo apt-get install libapache2-mod-wsgi
WSGIScriptAlias / /var/www/html/myapp.wsgi
to the end of the <VirtualHost *:80>...</VirtualHost>
block in file /etc/apache2/sites-enabled/000-default.conf
adduser
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