Linux Questions Flashcards
$
variable Use $ to retrieve the value of a variable, but not to create or change it.
/etc/password
contains all the accounts on the system -log in name, password info, user id, group id. etc….
ln
utility is used to create hard links
ln -s
utility is used to create soft (or symbolic) links
The -i option to ls
prints out in the first column the inode number
cat
Used for viewing files that are not very long; it does not provide any scroll-back.
tac
Used to look at a file backwards, starting with the last line.
less
Used to view larger files because it is a paging program; it pauses at each screen full of text, provides scroll-back capabilities, and lets you search and navigate within the file. Note: Use / to search for a pattern in the forward direction and ? for a pattern in the backward direction. (An older program named more is still used, but has fewer capabilities.)
tail
Used to print the last 10 lines of a file by default. You can change the number of lines by doing -n 15 or just -15 if you wanted to look at the last 15 lines instead of the default.
head
The opposite of tail; by default, it prints the first 10 lines of a file.
Displays Linux system information
uname -a
Displays kernel release information
uname -r
show which version of redhat is installed
cat /etc/redhat-release
show how long the system has been running + load
uptime
show system host name
hostname -I
show system reboot history
last reboot
show current date and time
date
show month;s calendar
cal
Quotes that contains strings and any variable or commands within them get evaluated or acted on
“double quotes”
Anything within these quotes gets treated literally, disables any special character functionality
‘single quotes’
This character disables any special character functionality that immediately follows it
\ (ie) $3.00 prints as $3.00 -won’t try to evaluate the 3.00 as a variable
_________ quotes around spaces or an escape character preceding a space will be treated literally
double quotes (or both double and single quotes)
\ (before”enter”)
Allows us to extend the command to multiple lines- this escapes out the enter key as the end of the command
________________What to do?
________________ How to do it?
________________ What to do it on?
Command
-Options
Arguments
searches a local database of files and folders looking for items that match the search criteria.
locate
searches the file system for files that match the search criteria. _____/path/to/folder -name * if we don’t provide a directory here, the command will start in the directory we are in. can give it part of the file name ‘*.xml’
find
locates binary source and/or man pages for a command
whereis
add a new user command?
adduser or useradd
a new user will typically own everything ______ and ______ the new users home directory.
including and beneath
Change ownership of the file named myfile to student use:
chown student myfile
changes the group ownership
chgrp
change the ownership and group ownership of many files at the same time, (only be used by the root user)
chown
ability to run commands as the root user without knowing the root password.
sudo
sudo users and which commands they can use are kept here.
/etc/sudoers
command that lets you edit the sudoers file
visudo
Allows us to extend the command to multiple lines- escapes out the enter key
\ (before”enter”)
disk usage command
df (disk free)
disk free human friendly
df -h
disk free inodes report
df -i
du
displays the number of disk blocks used by directories
displays the number of disk blocks used by directories
du
encoding information using fewer bits
data compression
compression utility on Linux - works on a single file
gzip
Changes ownership of the file named student to myfile
chown myfile student
To compress a group of files you may have to _____
collect them first with ar
other compression utilities on Linux
zip, unzip
bzip 2, bunzip2
backs up part or all of your files or filesystems
tar
tar will compress/uncompress if you use the ___ option
z
schedules a (1) job for future execution
at
schedules any number of jobs each at repeated times in the future
crontab
files that an administrator uses to control which users can use the cron and at commands
at. deny
at. allow
cron. deny
cron. allow
A file is stored in _____________ and then executed at the appropriate time by the ___ daemaon.
/var/spool/at/somename
atd
shows job number assigned to you (using at) #what is in the queue
atq
removes at job
atrm (then number of job ie 2)
In the past ________ was the packet manager of choice.
rpm (Red Hat Package Manager)
_____ extends the capabilities of rpm with additional features that simplifies package management
yum (Yellowdog Updater Modified)
One of the original text editors for Unix-like operating systems
vi
Successor to the vi text editor. Offers the same functionality plus extra features
vim
insert text under cursor in vim
i
writes the vim/vi files out to disk without quitting
:w
writes the vim/vi files out to disk (save), then quit (same as zz)
:wq
to append text to line in vim
shift a
to start an empty file in vim or vi, type:
vim (or vi)
Any keystroke that is a command for modifying script puts you in insert mode. Press _________ to go to ________ mode in vim.
escape, command
quit vim/vi without saving (ex command)
q!
When you are in command mode in vim, the following commands will move you into insert or append mode.
A move cursor to end of line
I move cursor to begining of a line
O open a line above where cursor is located
a move cursor to just after current character
i move cursor to just before current character
o open a line below where cursor is located
reads first 20 lines of somefilename
head -n 20 somefilename
reads first 10 lines of somefilename
head somefilename
reads last 20 lines of somefile
tail -n 20 somefilename
reads last 10 lines of somefile
tail somefilename
use tail to follow a command as it gets updated example
tail -f /var/log/secure
to stop a running tail
Ctrl + C
to stop any command that is running at the command prompt
Ctrl + C
grep
searches and prints out matches
searches and prints out matches
grep
grep < >
pattern
grep < >
file to search
grep ignore case
grep -i < file to search >
used to send output of one command as input to another
pipe command |
used to redirect standard output to new location
> (writes over) »_space; (appends)
searches for lines that begin with a given word
grep -i ‘^republic’ filename
finds lines that begin with a certain character
grep ‘^[Aa]’ filename
finds lines that do not begin with a certain character
grep ‘^[^Aa]’ filename
finds lines with a certain second character (h)
grep ‘^.[h]’ filename
find lines with www followed by anything
grep ‘www*’ filename
Changing user permissions to read and write only user
chmod 600 file or directoryname
verify permissions
ls -l