1/70
Looks like no tags are added yet.
first thing you always do
whoami
hostname
pwd
find directory, file size, who owns it, what group it belongs to
ls -l
delete a file
rm -f <file>
delete a directory
rm -r <dir>
create a directory
mkdir <name>
check options of a command
man <command>
3 types of file permissions
read, write, execute
each file permission can be controlled at 3 levels
user, group, other
command to change file permissions
chmod ugo+rwx
in file permissions first 3 bits, 2nd 3 bits, 3rd 3 bits
user, group, other
read a file
cat <file>
there are 2 owners of a file
user or group
change ownership of a file
chown <new-owner> <file>
change group ownership of a file
chgrp <new-group> <file>
log out of root
exit
what is an acl?
Access control list - flexible permision instead of u (every user) you can create an ACL for that specific user
show acl's
getfacl
use ACL to add permission for user
setfacl -m u:user:rwx /path/to/file
Add file permissions for a specific group
setfacl -m g:group:rwx /path/to/file
allow all files in an ACL to be cascading
setfacl -rm <u,g:name:rwx:> /path/to/dir
remove a specific acl entry
setfacl -x u:user:rwx
remove all acl entries from everyone
setfacl -b /path/to/file
3 types of help commands
whatis <command>
<command> --help
man <command>
use a help command
whatis <command>
man <command>
list all files that start with j
ls j<tab-key>
auto-complete commands
tab key
get all commands that start with
hit tab key TWICE
3 simple ways to add texts to files
vi
redirects » or <
echo
What is the difference between Chmod and setfacl
chmod only allows broad
Acl’s let you set specific file permissions
why do you do » instead of >
because if you only use > it’ll overwrite what you wrote
3 types of redirects in linux
standard input
standard output
error
file descriptor # stdin
0
file descriptor # stdout
1
stderr file descriptor #
2
the output of a command can be routed to a file using
>
route the output of ls -l to a file
ls -l > file
view hidden files
ls -la
when a command is executed on the keyboard
stdin - 0
when a command is displayed on the screen
stdout - 1
if a command showed an error message
stder - 2
Tee command is used to
store and output at the same time (it’s like saving a redirect »)
why do you do | tee -a
-a = append → same thing as » vs >
tee command syntax
ls -l | tee -a
find how many characters you have in a file
wc -c <file>
use a pipe command
ls -l | more
view the end of a command output
ls -l | tail
view output one page at a time
ll | more
execute multiple commands
ls ; cd ; pwd
copy a file
cp <source> <new-name>
copy a file but move it to a different location
cp <file> /path/to/dir
remove a file
rm <file>
rename a file
mv <source> <new-name>
move a files location
mv <source> /path/to
create a directory
mkdir <name
delete a directory
rmdir <name>
remove a directory without using rmdir
rm -Rf <name>
change group owner of a file
chgrp <newowner> <file>
change the file owner
chown <new-owner> <file>
change owner/group of a file in one command line
chown <owner>:<group> file
read one page at a time
more <file>
get prompt back when using more command
q
read a file one line at a time
less <file>
What is the difference between the more command and less command
more = one page at a time
less = one line at a time
view the end of a file
tail -2 <file>
view the top of a file
head -2 <file>
get the first character of each line in a file
cut -c1 <file>
get a range of characters out of a file
cut -c1-3 <file>
get multiple ranges of characters out of a file
cut -c1-3, 6-8 <file>
what is a delimiter
what seperates lines like → :
where is the delimiter in cut -d: -f # <file>
What does -f stand for?
delimiter → :
-f stands for field
get characters out of a file by specifying the delimiter
cut -d: -f # <file>