RH124 Commands to Know
Overview of syslog priorities
0 emerg: system is unusable 1 alert: action must be taken immediately 2 crit: critical condition 3 err: non-critical error condition 4 warning: warning condition 5 notice: normal but sufficent event 6 info: informational event 7 debug: dubgging-level message
Overview of syslog facilities
0 kern: kernel messages 1 user: user-level messages 2 mail: mail system messages 3 dameon: system dameons messages 4 auth: authentication and security messages 5 syslog: internal syslog messages 6 lpr: printer messages 7 news: network news messages 8 uucp: uucp protocol messages 9 cron: clock dameon messages 10 authpriv: non-system authorization messages 11 ftp: ftp protocl messages 16-23 local0 to local7: custom local messages
signal
ANSI C signal handling
echo \$HOME
An escape character in the bash shell. Protects against the following character from expansion
systemctl
Control the systemd system and service manager
groupadd
Create a new group
ln -s
Creates a symbolic link
groupdel
Delete a group
su -
Enter root shell
sudo
Execute a command as another user
- is a regular file d is a directory l is a symbolic link c is a character device file b is a block device p is a named pipe file s is a local socket file
First character of the long listing is the file type
Nine characters that represent file permissions
First three apply to file owner second three apply to file's group owner last set applies to all other users
evince
GNOME document viewer
killall
Kill processes by name
newgrp
Log into a new group.
ln
Make links between files (hard links)
usermod
Modify user account
/var/log/messages
Most syslog messages are logged here
/var/log/boot.log
Non-syslog console messages about system startup
ssh_config
OpenSSH client configuration files
*b*
Pattern matches all files that contain a "b"?
[[:upper:]]*
Pattern matches only file names that begin with an uppercase letter?
???
Pattern matches only file names with at least three characters?
*[[:digit:]]*
Pattern matches only file that contain a number?
b*
Pattern matches only files that begin with "b"?
*b
Pattern that matches file names that end with "b"?
[!b]*
Pattern that matches only the file names where the first character is not "b"?
whoami
Print effective userid
2> file
Redirect stderr to overwrite a file
>> file
Redirect stdout to append to a file
> file
Redirect stdout to overwrite a file
echo '$(command)'
Single quotation marks protect all shell expansion
/var/log/maillog
Syslog messages about mail server
/var/log/cron
Syslog messages about scheduled job execution
/var/logs/secure
Syslog messages about security and authentication events
uptime
Tell how long the system has been running
SSH (Secure Shell)
The most common way to get a shell prompt on a remote system is using Secure Shell. The ssh command encrypts the connection to secure the communication.
passwd
Update user's authentication tokens
/etc/vimrc and ~/.vimrc
Vim configuration file
Changing persmissions with symbolic method chmod Who/What/Which file|directory
Who u - user g - group o - other a - all What + - add - - remove = - set exactly Which r - read w - write x - execute X - special execute
vi/vim
a text file editor in linux
ssh-add
adds private key identities to an authentication agent
man
an interface to the on-line reference manuals
ssh-agent
authentication agent
ssh-keygen
authentication key generation
cd
change directory
touch
change file timestamps. Can be used to create empty files
chage
change user password expiry information
(vim) :q!
command quits vim, and discards all file changes since the last write
(vim) :w
command writes the file and remains in command mode for more editing
cat
concatenate files and print on the standard output
timedatectl
control the system time and date
cp
copy a file or directory
sleep
delay for a specified amount of time
(vim) x
deletes a single character
2> /dev/null
discard stderr error messages by redirecting to /dev/null
echo
display a line of text
pstree
display a tree of processes
echo ${VARIABLENAME}
display a variable in stdout
top
display all running processes
lscpu
display information about the CPU architecture
echo $(command 1)
display the output of a command in stdout
history
displays a list of previously executed commands prefixed with a command number
date
displays the current date and time. +%R shows time and +%x shows the date.
Network interface names
ethernet interfaces begin with "en" WLAN interfaces begin with "wl" WWAN interfaces begin with "ww"
r (read)
file and contents can be read
w (write)
file contents can be changed
x (execute)
files can be executed as commands
VARIABLENAME=value
format for declaring a new variable in Bash
systemd-journald
hear of OS event logging architecture. Collects event messages from many sources: system kernel, output from the early stages of the boot process, stdout and stderr from dameons, syslog events
(vim) u
key undoes the most recent edit
ls
list directory contents
pgrep, pkill
look up or signal processes based on name and other attributes
mkdir
make directory
mv
move a file to another location
head
output the first part of files
tail
output the last part of files
command1 | command2
pipe the output of command1 to the input of command2
wc
print newline, word, and byte counts for each file
id
print real and effective user and group IDs
pwd
print working directory
PID
process id
tee
read from standard input and write to standard output and files
>> file 2>&1 and &>> file
redirect stdout and stderr to append to the same file
> file 2>&1 and &> file
redirect stdout and stderr to overwrite to the same file
rm
remove file or directory
ps
report a snapshot of the current processes
df
report file system disk space usage
su - username
run a command with substitute user and group ID
file
scans the compiled header of a file for a 2-digit magic number and displays its type
find
search for files in a directory hierarchy
rsyslog
service reads syslog messages that the systemd-journald service receives from the journal as they arrive.
w
show who is logged on and what they are doing
kill
terminate a process
Effects of special permissions on files
u+s (suid) - file executes as the user that owns the file, not as the user than ran the file g+s (sgid) - file executes as the group that owns the file o+t (sticky) - no effect
Effects of special permissions on directories
u+s (suid) - no effect g+s (sgid) - files that are created in the directory have a group owner to match the group owner of the directory o+t (sticky) - users with write access to the directory can remove only files that they own; they cannot remove or force save to files that other users own
ssh-copy-id
use locally available keys to authorize logins on a remote machine
(vim) p
vim "put" command aka paste
(vim) y
vim "yank" command aka copy
(vim) :wq
write and quit the file editor