Linux mod 5 Flashcards
A program that provides text only interface for Linux and other UNIX like OSs.
Presents each user with a prompt, executes user commands and supports a custom environment for each user.
Shell
What does the # symbol indicate in
[root@Linux ~]#
Root user
What does the $ or % indicate
[bob@localhost ~]$
Non-root user
What are the different shells available?
Bourne Shell (sh)
Tenex C Shell(tcsh)
C Shell (csh)
Bourne-Again Shell (bash)
Display on-line manual pages about command.
man
Syntax: man
Clears the current screen
clear
Print working directory, displays the current working directory.
pwd
Displays the UNIX OS variant.
uname
uname -a Prints all information
Prints or sets the system date and/or time.
date
date -s
Sets date to date and time provided.
Lists directory contents in a tree-like format.
tree
tree -c Turn colorization on
tree -f Append a “/“ for directories
Exit the current shell
exit
Lists contents of a directory
ls
ls -l Long-list - shows ownership, permission, and links.
ls -i Inode number in the first field
ls -s number of file system blocks
ls -a List all files including invisible files
What are text files are viewed using text viewer utilities?
Don’t change file contents but allow forward and backward navigation as well as search.
Pagers
Displays text files one screen at a time.
less Options: -b Backwards movement, one page at a time / Initiates a search for a string (word) q Exits from less SPACE BAR Advances one screen at a time ENTER Key Advances one line at a time
Works like the less command but with fewer options.
more
Automatically prints the first 10 lines of a file to standard output.
head
Syntax: head
Command automatically displays the last 10 lines
tail
Syntax: tail
Displays file(s) contents to the screen and can concatenate (combine) files.
cat
Syntax: cat
cat >
Change directory
cd
Syntax: cd //
cd
Static files of the boot loader; required to boot the system.
/boot
Essential command binaries (e.g., cp, mkdir, ls, less).
/bin
Essential system binaries. Commands intended for use by privileged users.
(e.g., init, fdisk, ifconfig, lsmod).
/sbin
Second major hierarchy. User system resources, i.e., user binaries, and associated documentation, libraries, and header files
/usr
Shared libraries.
/lib
Device files (block and character).
/dev
System administration and configuration files.
/etc
User home directories.
/home
Optional third-party software.
/opt
Processes used by system.
/proc
Root user’s home directory.
/root
Temporaru files used by the system
/tmp
Variable size data like that found in log files
/var
In UNIX, the
current working directory is displayed using the ___ (print working directory) command.
pwd
The _______ is based on the present working directory.
relative path
An _______ in UNIX begins at the root ( / ) directory.
absolute path
Displays text to standard output.
echo
Syntax:
echo
The path statement is modified using the ____ command
PATH
Example:[root@localhost etc]# PATH=$PATH:/usr/demo
[root@localhost ~]# echo $PATH
All UNIX variances come with a visual editor pre-installed.
vi
normally supplied with all UNIX systems
requires very little memory
uses standard alphanumeric keys for commands
Syntax vi
Which modes does vi have?
There are only two modes of operation in the vi editor:
Command Mode Characters typed perform actions like moving the cursor, cutting or
copying text, or searching for a particular text string. vi opens in
command mode.
Insert Mode Actual text is typed or overwritten.
Insertion commands for vi:
i Insert before cursor
a Append after cursor
o Insert below current line
O Insert above current line
yy Copy line into memory (yank-yank)
p Works with yy to place copied line onto the existing or next line
5p Places five lines of what was copied, at cursor
Deletion commands
x Delete current character
r Replace current character
dd Delete current line
Navigation commands
h Move cursor one place to the left
l (lower case L) Move cursor one place to the right
j Move cursor one place down
k Move cursor one place up
/ Searches within the document for a string
Exit commands
:w Writes (saves) latest changes to the file
:q Quits, leaving vi open in command mode
:q! Quits vi without saving changes
:wq! Saves file and any changes, and quits vi.
Creates an empty file and is also used to modify a files timestamp.
touch
Options: -a Manipulates the file’s access date/time stamp
Syntax: touch
touch -a YYMMDDHHMM
Creates one or more directories
mkdir
Options: -p Creates a directory where no parent exists (nested)
Syntax: mkdir
mkdir -p //
Copies files and directories
Options: -r Recursively copy directories.
Syntax: cp
cp –r
Moves or renames files and directories.
mv
Syntax: mv
Creates a link between files and directories.
ln
Options: -s Creates a symbolic link to another file.
Syntax: ln -s
Removes a file or a directory with contents if using the -r option.
rm
Options: -r Remove a directory and its contents recursively
-f Ignore nonexistent files, never prompt (force).
Syntax: rm
rm -rf
Searches a file or files for lines that contain strings of a certain pattern.
grep
Syntax: grep
Locates files having certain specified characteristics.
find
Syntax: find -
Displays full path (location) or most (shell) commands.
which
Syntax: which
Determines file type
file
Syntax: file
Displays a snapshot status of active processes. A process running in the
background is called a daemon.
ps Options: -e Lists information about every process running -l Displays in a long format -f Generates a list in full mode format Syntax: ps -elf
Stops a process from running using its PID
kill
Options: -9 Used to kill a stubborn process that won’t die
Syntax: kill [option]
Stops a process from running using its process name.
pkill
Options: -9 Used to kill a stubborn process that won’t die.
-HUP Used to immediately re-spawn a process to effect
configuration changes. After modifying a daemon’s
configuration file, use pkill -HUP to hang up and
restart the daemon with the new configuration.
Syntax: pkill [option]
Maintains a history file of all commands run by a particular user in that shell.
history
history is also used to run previous commands by using an exclamation point (!)
followed by the corresponding line number in the history output.
Syntax: !
Prints the strings of printable characters in a file (not ASCII characters). Useful in determining contents of nono-text files (executables)
strings
strings
Creates a typescript of the terminal session (everything printed on the terminal).
CTRL+d ends the script session. View results using less.
script
script
Used to switch from the current user account to another. It is often used to
switch to root user to perform tasks requiring elevated privileges.
su
su
Displays who the user is logged in as at this moment (after switching user)
whoami
Syntax: whoami
Displays user login information including login name, time, terminal, and more.
who
Syntax: who
Displays information about the user(s) logged in and what they are doing
w
_________is used on audio data because some
portions of the data can be thrown away without significant degradation of sound quality.
Lossy Compression
______compression creates a file smaller than the original that can later be reconstructed,
maintaining all of its data and metadata.
Lossless
Compresses files and appends a .gz file extension. The original file is replaces.
gzip
Syntax: gzip
Decompresses a file that was compressed with gzip.
gunzip
Syntax: gunzip
The tape archive
___ command is an archiving utility that has been around since the early days of UNIX and was
designed to archive data to a tape drive.
tar
Tape archive utility used to archive files to tape or disk.
tar
Options: c Create an archive
t List table of contents of tar file
x Extract, must be in target directory to extract
z Compress the archived file using gzip (tarball)
v Verbose, list each file as tar reads/writes
f Read/write to or from a file
C Change to directory
Syntax: tar -[options]
Schedules a job/process for a one-time execution.
at
Syntax: at ENTER
at>
[CTRL+d] Places the job into the queue and exits
Lists user’s pending jobs.
atq
Deletes user’s jobs identified by job number.
atrm
Schedules periodic jobs. The cron daemon (crond) checks the /etc/crontab every
minute for any jobs that need to run. To create a cron job, the cron table
(crontab) is created or modified.
crontab
Options: -e Edit the crontab
-l List crontab entries
Creates a new user or updates default new user information.
useradd
Options: -d Specifies the path of the user’s home directory;
Linux - users’ home directories are in /home
-m Makes a home directory if it doesn’t already exist
-n Assigns whatever group is in default
Syntax: useradd -d /home/ -m -n
Deletes a user account
userdel
Options: -r (Recursively) Removes the home directory for
specified user
Syntax: userdel -r
Enables a user to change their password (no user name) or for root to set and
modify password settings.
passwd
Syntax: passwd
Contains the system wide environment and startup programs. When a
user logs on to a system for the first time and/or does not have a profile,
the settings contained in the systems file are used to create
the user’s profile.
/etc/profile
A tilde (~) references paths that start with a user’s home directory. Depending upon the shell and type of login used, users customize their environment by modifying either ~/.bash_profile,~/.bashrc, or ~/.profile.
~/.bashrc