Stuart Linux Flashcards
Augment: Display more details about files in current directory.
ls -l
Augment: Display all files(even the hidden ones)
ls -a
How do you find out a file type of a file?
file
While using the less command how would you find the word “server3”
/server3
How would you copy the file test.1 to /home/bin
cp test.1 /home/bin
Augment: how would you copy a directory “dir1” to /home/lib
cp -r dir1 /home/lib
How would you search for a file named networkinfo.txt throughout the system and again through the /home/bin folder
find / -name networkinfo.txt
find /home/bin -name networkinfo.txt
How would you output the list of objects in your current directory to the sample.txt file
ls > sample.txt
> Overwrites
» adds the output to the end
How would you see what the home directory is?
echo $home or env
How would you extract the 10 character from each line of sample.txt? how about the 3rd field?
cut -c 10 sample.txt
cut -f 3 sample.txt
How would you sort sample.txt alphabetically and numerically?
sort
sort -n
How do you get the character/word/line count of a file
wc (-c/w/l)
this command add numbers beside each line
nl
This lets you search for words or numbers in a file. also how do you make it case insensitive
grep
grep -i
how to VIM edit a file
VIM file
how to enter insert mode
i
how to copy a letter/line in VIM
y for a character and yy for a line
how to delete in vim
d in command mode delete or backspace otherwise.
in VIM how to get out of insert mode
esc
how to paste in VIM
p
in VIM how to save
:w
in VIM how to quit
:q
or :q! to quit without saving
how to save and exit in VIM
:wq or ZZ
Location of where user information is held
/etc/passwd