Lesson 6A Managing Linux Flashcards
Shell
Provides a command environment by which a user can operate the OS and application.(Bash, zsh, and ksh(Korn Shell))
Terminal
Software that implements input and output for a command shell. The Terminal and the Shell are connected by a teletype device.
stdin(0)
Takes the user’s keyboard input and writes it as data to the tty device for processing by the shell command interpreter.
stdout(1)
Reads data generated by the shell from the tty device and displays it through the terminal.
stderr(2)
Carriers error information.
Console Switching
Device that implements input and output for a command shell.
CTRL+ALT+Fx keys can be used to switch consoles.
Commands
The first “word” input is interpreted as the command.
Options(switches) - Are used to change the operations of a commands.
Arguments- Values supplied to the command for it to operate on, such as file names.
Pipe command(|)- Allows the usage of two commands.
Case Sensitivity
Commands, Parameters, and files and directory names are all case sentitive in Linux.
ls -l and ls-L will produce different outputs.
Help System
Reports the functions and syntax when executed as –help. Ex. ls –help | more
Nano
Nano text editor. nano filepath or nano -| filepath showing line numbers.
CTRL+O writes changes to the files.
CTRL+X quits the editor.
Vi or Vim
Preferred by Administrators
Switches
i - switches to insert mode at the current cursor position.
a- appends text after the current position.
A- appends text at the end of the current line
o- insert text on a new line below the current line.
ESC key- switches from insert mode back to command mode.
: set number- Shows line numbers in command mode.
:w- saves the file.
:wq- saves and quits
:q! - quits without saving
Navigation Commands
pwd Command
Print the working directory that you are currently using.
cd Command
Used to change directory.
cd /etc leads to an absolute directory.
cd document leads to subdirectory(relative path) named documents.
cd ..
ls Command
List the contents of the directory
Switches
-l - displays a long list
-a - displays all files including the hidden ones.
cat Command
Returns the content of the files listed as arguments.
Switches
-n- adds line numbers to the output.
Overwrite = cat > file
Append = cat»_space; file
Search Commands
find Command
is used to search for files.
grep Command
Used to search and filter the contents of a file.
File Management Commands
cp Command
Used to create a copy of a file in the same or a different directory with the same name or a different name.
rm Command
Can be used to delete files.
-r can be used to delete a directory
mv
Used to either move a file from one directory to another or to rename a file.
df Command
Disk Free
Enables to see the disks free space, file system, total size, space used, percentage valuie of spaced used, and mount point.
du Command
Disk Usage
Displays how a device is used, including the size of a directory tree.
User Account Commands
su Command
Used to switch users: su username
su - will prompt the superuser account.
sudo Command
allows any account listed in the /etc/sudoers file user to run specified commands with superuser privilege level
User Management Commands
useradd- add user data
usermod- modify user data
userdel-delete user data
Group Management Commands
groupadd
groupmod
groupdel
Used to manage group permissions
File Permissions Commands
Read
Write
Execute
(r)Gives permission to view the content of a file or directory.
(w) Gives permission to modify or delete the file.
(x) Gives permission to run an executable file or script.
Permissions expressed numerically
Read = 4
Write = 2
Execute = 1
Denied = 0
chmod
Can be used to secure files and directories, using either symbolic notation o roctal notation.
Only the owner can change permissions.
chown Command
Allows the superuser to change the owner of a file or a directory.
Can only be used by a superuser or sudoer.
Package Management Commands
apt-get update Command
Refresh the local database with information about the packages available from the repository.
apt-get upgrade Command
C
apt-get install PackageName
Installs a new application.
yum check-update
Refresh the local database with information about the packages available from the repository.
yum update
Refresh the local database with information about the packages available from the repository.
yum install PackageName
Installs a new application.
Process Monitoring Commands
Every process is assigned a unique Process ID when it is started so that the system can identify the process.
ps commands
Invokes a process table, a record that summarizes the currently running programs on a system.
top Command
List all the processes running on a Linux System. It acts as a process management tool by enabling you to prioritize, sort, or terminate processes interactively.
Top Options
ENTER Refresh the status of all processes.
SHIFT+N Sort processes in the decreasing order of their PID.
M Sort processes by memory usage.
P Sort processes by CPU usage.
u Display processes belonging to the user specified at the prompt.
q Exit the process list.
Network Management Commands
ifconfig
Part of the legacy net-tools package
Safely be used to report the network interface configuration.
ip addr
replicates the basic reporting functionality of ifconfig
report a single interface only, use
ip addr show dev eth0
ip link
ip link command shows the status of interfaces, while
ip -s link reports interface statistics.
dig command
Utility to query a DNS server and return information about a particular domain name or resource record.
Samba
Linux software package that implements Server Message Block (SMB) file/print sharing, primarily to support integration with Windows hosts.
Backup and Scheduling Commands
In Linux their is no official “backup”. Cron can be used as a task scheduler and file copy scripts.
crontab -l
Reviews a user’s contab job.
crontab -r
Remove jobs from the scheduled list.
crontab -e
uses the vi editor
Basic syntax for scheduling a job.
mm - minutes (0-59)
hh- hours(0-23)
dd- days (0-31)
MM- months(1-12) or jan, feb, mar
weekday- (day of the week(1-7 or mon, tue, wed))
command-command or script to run (include the file path)