linux commands Flashcards
what does the kernel on UNIX do?
it is the hub of the op system - ALLOCATES TIME + MEMORY TO PROGRAMS -
also handles filestore + comms in response to system calls
what does the shell do on UNIX do?
acts as interface between user + kernel
to list personal files and subdirectories
ls
ls doesnt always list everything, just those not prefixed with a dot (HIDDEN FILES). how do you make a list inclusive of these
ls -a
how to display username
whoami
how to make directory
mkdir dirname
how to change directory
dc dirname
how to stay in directory you are in
cd .
how to navigate to parent directory
cd ..
pathnames enable you to work out where you are in file system. how do you print this out?
pwd
home directories can also be referred to by tilde character - can be used to specify paths starting at home directory
ls ~/dirname
how to copy file
cp file1 file2
how to create a file
touch filename
how to create backup
rename filename.txt to filename.bak
how to move/rename file
mv file1 file2
how to remove a file
rm filename
how to remove a directory
rmdir directoryname
to clear screen
clear
what does the command cat (concatenate) do?
displays contents of file to screen
what does the head command do?
displays first 10 lines of file to screen
what effect will typing in -5 do to head command?
deducts last 5 lines from the 10 displayed
what does tail command do?
displays last 10 lines of files
what does grep do? specify the syntax
displays a specified word from the file to screen. grep science science.txt
what option is used to ignore uppercase and lowercase letters?
grep -i science science.txt
what syntax is used to search for a specific phrase?
grep -i ‘spinning top’ science.txt
what are the other options of grep and their meanings?
-v display those lines that do not match
-n precede each matching line with line number
-c print only total count of matched lines
what syntax is used to perform a word count?
wc -w science.txt
what syntax is used to perform a line count?
wc -l science.txt
how to write contents to a file
cat > list1
pear
banana
apple
^D
how to read the contents of a file
cat list1