3. Philosophy of Linux
• Linux does not assume anything.
• Lets you install what you need rather than give you a bunch of things
you may not need
• Linux commands and case sensitive
1/23/2016 3
4. Terms
Term
Kernel Takes care of resource allocation
Shell Accepts command and passes it to kernel
Service Application that runs in the background
1/23/2016 4
5. Releases
lsb_release -a Prints the release, codename and description
lsb_release -sc Prints the codename
ubuntu-support-status Check status of the release and packages
uname -r prints kernel version
Release Upgrade Steps
sudo apt-get update Step-1
sudo apt-get update update-manager-core Step-2
sudo do-release-upgrade Step-3
1/23/2016 5
6. File System - Important Directories
/var/run pids for important processes
/var/log log files
/etc/init Configuration Files
/etc/init.d Scripts that respond to start and stop
/etc/hosts DNS
/etc/passwd User database
/etc/ssh SSH configuration
/etc/my.cnf MySQL configuration
/opt/ Optional packages not part of the default installation
~ Home directory
~/.ssh Known Hosts, Authentication Keys
~/.bash_profile Startup File. Defines aliases and configuration
1/23/2016 6
7. Package Management
apt Advanced Packaging Tool
/etc/apt/sources.list Stores the list of available packages
deb – Repos containing binarires
deb-src – Repos containing source code for packages
sudo apt-get update Checks for new versions
sudo apt-get install nmap To install the package nmap
sudo apt-get remove nmap To remove the package nmap
1/23/2016 7
8. Environment Variables
env View all environment variables
env | grep PATH
echo $PATH
echo $USER prints current user
1/23/2016 8
9. Processes
Processes are the core of Linux OS. A process is an instance of a running command.
init First process with id 1. Cannot be killed. Every other process is a child of init
daemon is a background process
htop interactive tool to list and manage processes
Prints CPU & memory utilization of each process
crontab –l list all background scheduled processes
crontab –e edit the crontab
1/23/2016 9
10. User Management
compgen –u List all users
compgen –g List all groups
sudo su – user2 Switch to user2
sudo Run commands as root user
1/23/2016 10
11. Command Enhancements
time cmd prints the time taken to execute cmd
cmd1 | cmd2 pass the output of the previous cmd1 to in the input
of the next cmd2
cmd & Execute cmd in the background and return
./cmd bypass an alias
man cmd Manual entry for cmd
whatis cmd Documentation for cmd
screen -x screen sharing between users
1/23/2016 11
12. Aliases
Aliases help replace 1 string with another while execution. Aliases are usually defined in the configuration file
like .bash_profile
alias ll=“ls—l” Creates an alias
alias ll gets the alias
single quotes variables are not expanded
double quotes variables are expanded
1/23/2016 12
13. Network Management
netstat -ntlp Network Statistics - List of ports listening
telnet host port Check if the port on the host is listening
iostat Input Output Statistics
host google.com DNS lookup
ping google.com Check is server is active
du disk usage statistics
ifconfig Configure network interface parameters
1/23/2016 13
14. Terminal Tips & Misc
cmd + R clears terminal
ctrl + R Search through command history
sudo reboot reboot machine & logout
#! /bin/bash Hash bang. First line of a script. Uses bash interpreter
1/23/2016 14