# 3. Linux Refresher
[toc]
**Linux creator --> Linus Torvalds**
### Linux Major Families and Flavours
:::warning
- Redhat Family (RPM)
- Redhat Enterprise Linux (RHEL)
- Fedora
- CentOS
- suse
- Debian (apt)
- Ubuntu
- Debian
- Mint
:::
### Linux command-line tasks:
:::warning
1. Check the hostname
2. Check the current user logged in
3. Date / time of the instance
4. How long the instance has been running?
5. How to check if git is installed on the instance?
6. Check ubuntu version?
7. check the file partitions
8. Create a directory named “testdir”
9. Create a directory inside “testdir” by name “nested-demo”.
10. go into directory “nested-demo”
11. Install Package “tree”
12. Validate if package tree is installed successfully.
13. Check if Docker is installed on your instance
14. Check the software version of Docker, if it is installed.
15. Get the history of your last run commands
16. Move into directory nested-demo (if not there already) and create a file called “testfile.md”
17. Edit testfile.md and add the following line:
```This file was created as part of the Linux refresher session for DevOps certification course```
17. Validate the testfile.md file and see if the line is added.
:::
### Linux command-line tasks (solutions):
:::warning
1. Check the hostname
hostname -a
2. Date / time of the instance
date
3. How long the instance has been running?
uptime
4. How to check if git is installed on the instance?
which git
5. Check ubuntu version?
lsb_release -a
6. check the file partitions
df -h
7. Create a directory named “testdir”
mkdir testdir
8. Create a directory inside “testdir” by name “nested-demo”.
mkdir testdir/nested-demo
9. go into directory “nested-demo”
cd nested-demo
10. Install Package “tree”
apt install tree
11. Validate if package tree is installed successfully.
which tree
12. Check if Docker is installed on your instance
which docker
13. Check the software version of Docker, if it is installed.
docker --version
14. Get the history of your last run commands
history
15. Move into directory nested-demo (if not there already) and create a file called “testfile.md”
cd nested-demo && testfile.md
16. Edit testfile.md and add the following line:
```This file was created as part of the Linux refresher session for DevOps certification course```
echo "This file was created as part of the Linux refresher session for DevOps certification course" >> testfile.md
17. Validate the testfile.md file and see if the line is added.
cat testfile.md
:::
### More Linux commands
````yaml=1
lsb_release -a
cat /etc/centos-release
cat /etc/redhat-release
cat /etc/os-release ## For Ubuntu
ifconfig
ip -a
ip -r
date
uptime
useradd
usermod
userdel
ping
dig
traceroute
grep
chmod
chown
netstat
su - <username>
sudo -i
sudo su -
top
ps -ef
ps -ef|grep <process name>
mount
systemctl status service-name command
ctrl+c
````
````yaml=
cp filename destination: to copy file
mv filename destination: to move or rename a file
cp -r <source> <destination>: to move folder from one to another
ls -l: to list all the files and folders
ls -a: to list all file and folders including hidden ones
````
### Working with vi text editor
````yaml=1
edit the file
vi <filename>
i --> insert mode
esc --> come out of insert mode
esc + wq! + enter --> save the file and exit
esc + q! + enter --> exit the file without saving
esc + w! + enter --> save the file and keep editing
````
### References
:::success
**Linux**
- [The Linux Command Handbook - freeCodeCamp](https://www.freecodecamp.org/news/the-linux-commands-handbook/)
- [Linux Journey](https://linuxjourney.com/)
- [The Linux command line for beginners - Ubuntu Tutorials](https://ubuntu.com/tutorials/command-line-for-beginners)
- [Introduction to Linux (LFS101x)](https://training.linuxfoundation.org/training/introduction-to-linux/)
- [Hands-on Introduction to Linux Commands and Shell Scripting](https://www.coursera.org/learn/hands-on-introduction-to-linux-commands-and-shell-scripting/)
- [Linux - The Complete Reference.pdf](https://doc.lagout.org/operating%20system%20/linux/Linux%20-%20The%20Complete%20Reference.pdf)
- [Understanding Linux permissions - Pluralsight](https://www.pluralsight.com/blog/it-ops/linux-file-permissions)
**Shell Scripting**
- [Shell Scripting for Beginners – How to Write Bash Scripts in Linux](https://www.freecodecamp.org/news/shell-scripting-crash-course-how-to-write-bash-scripts-in-linux/)
- [Bash Scripting Tutorial – Linux Shell Script and Command Line for Beginners](https://www.freecodecamp.org/news/bash-scripting-tutorial-linux-shell-script-and-command-line-for-beginners/)
- [Mastering Linux Shell scripting](https://github.com/mehransab101/Mastering-Linux-Shell-Scripting/blob/master/Mastering%20Linux%20Shell%20Scripting.pdf)
- https://www.learnshell.org/
- [Shell scripting tutorial](https://www.youtube.com/playlist?list=PL7B7FA4E693D8E790)
**Python**
- [CS50’s Introduction to Programming with Python](https://cs50.harvard.edu/python/2022/)
- [The Python Tutorial [Official]](https://docs.python.org/3/tutorial/)
- [100 days of python code](https://replit.com/learn/100-days-of-python)
- [Python for Beginners – Full Course [Freecodecamp Programming Tutorial]](https://www.youtube.com/watch?v=eWRfhZUzrAc)
- [Real Python Tutorials](https://realpython.com/)
:::