Linux Flashcards
(34 cards)
Create a tree structure recursively
Mkdir -p ~/myFile/file/filenote
How to make a file with out gedit
touch filename
Kate fileName
vi fileName (I to insert, shift zz to exit)
Leafpad
All the ways to extract a bit of a file
sed -n 1~2p
-n line #; p print;
, inclusive range;
head
tail
How to find info on a specific command
man
Sort switches
sort -k 2d fileName
-k column #
2d column #\ data type
Column 2 alphanumeric
3n column 3 numerically
What does the crontab do?
Enables you to regularly schedule reoccurring jobs.
crontab -e
Join 2 files together column wise
Cat»_space; ~/trials/file1
For typing what to add
Cat file1»_space; file2
Joining 2 files
Know about the calendar
cal 05 2017
05 month
2017 year
You can’t specify the day
How to compress/ uncompress a file
Gzip -l file1
(To zip the file)
(Will give it a .gz)
gunzip file1.gz
How to get the unique files out of a file
uniq file one
(To view)
uniq file1 > uniqFile1
(To take out)
How to count stuff in a file
wc file1
(Just one file)
wc file1 file2 file3
(You can do more then one file at a time)
What do the wild cards do
*0 or more matching chars in a fileName
?represents a single char
[] A range
Absolute path and relative path
View the parent of:
/home/student/devices/routers/
Absolute:
ls /home/student/devices/
relative:
ls ..
Create a link to the:
/home/student/inventory
ln -s /home/student/inventory /home/student/inventory.bak
Must use absolute path
To unlink:
unlink
Understand the permissions
(-)[---]{---} 11 ()file type []you {}group <>other 11 # of hard links Directory, read, wright, execute, -file
How to move files in the tree
mv ./file1/file2 ./file1/file3
Remove a directory recursively
rm -rvi file1
Yes to all
Change permissions symbolically
Chmod u+r+w+x,g+r+w,o+r file1
Change permissions numerically
chmod 764 file1
4 read
2write
1 execute
0 fuck all
Find file types
find -name "*a"/ "a*" find -cmin 1 find -links 3 find -size 57c find -type l, f, d find -user student
Make a new user and change there password
sudo useradd -m -d /home/user1 user1
Sudo passwd user1
sudo cat shadow
Display environment variables
env
SHELL=/Bin/bash USER=student SUDO_COMMAND=/bin/bash PWD=/home HOME=/home/student LOGNAME=student OLDPWD=/home/student
What does the ~ and !~ operators mean
~ = matches !~ = does not match
Joining 2 files together row wise
Paste -d file1 file2
Or to make a new file
Paste -d “ “ file1 file2 > file3