Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11 Command-Line Master Class

Similar presentations


Presentation on theme: "Chapter 11 Command-Line Master Class"— Presentation transcript:

1 Chapter 11 Command-Line Master Class
Ubuntu Unleashed Chapter 11 Command-Line Master Class

2 Why Use Command Line? You want to string multiple commands together
Some commands are only available through the shell Most server installs have no GUI – if you want to run the server you must know CL You're a Linux guru, or want to be.

3 Basic Commands 25 recommended commands... cat – print file contents
cd – change directories chmod – changes file permissions cp – copies files du – shows disc usage emacs – edit text files find – find files gcc – compiles some programs grep – searches for a text string

4 Basic Commands cont. less – allows paging through long files
ln – creates links between files locate – find files from an index ls – list of files in current directory 25 recommended commands...continued make – compiles and installs programs man – displays manual pages mv – move or rename files ps – lists processes rm – removes files

5 Basic Commands cont. ssh – secure shell client
tail – prints the last lines in a file top – prints resource usage vim – edits text files which – prints the location of a command xargs – executes commands from its input

6 Advanced cat cat – basic use – print file (on screen) Advanced use
Merge 2 or more files cat myfile.txt myfile2.txt Remove all but one blank line per line of text cat -s myfile.txt Number the output lines cat -n myfile.txt Use multiple switches cat -sn myfile.txt

7 ADV chmod Switch -c Prints a list of changes on screen
chmod -c 777 myfile.txt will respond with “mode of 'myfile.txt' changed to 777” Switch -R Will change permissions of a directory and all files within Switch --reference Allows you to specify a file and apply its permissions chmod --reference reference_file myfile.txt

8 ADV cp Two switches --parents
Copies full path of the file into the new directory Lets you know where the file was copied from -u Allows for synchronizing of files – will not overwrite newer data cp -u myfile mybackupfile

9 du du – disc usage Prints size of each directory (and how much space the files take up) inside current directory du du -a – prints the size of individual files, as well as directories du -h – makes du “human readable” – puts output in megabytes du -c – prints total size of files

10 find find command – underutilized due to too many options/switches
Basic use – find -name “*.txt” Will return all .txt files within directory and subdirectories to include case variations (upper/lower) replace -name with - iname size switch Find -name “*.txt” -size 100k (or +100k or -100k) Can also add “not” “user” and “perm” (for permissions) options Can get very complex

11 grep Another search tool Searches for text strings within files
grep “this text that I'm looking for” * Will list filename and line of text - within directory Use -r to search subdirectories grep -r “this text” * Invert search with -v Grep -v “this text” myfile.txt Will show any line of text from file that does NOT have the words “this text”

12 less Sometimes a better option than “cat”
Allows you to scroll through the material Works like “man” pages (q to quit, etc) less filename Loads of switches (one for every letter of the alphabet, and more!) Can even open a bash session from within “less” and then return.

13 ln Creating Links with ln
Two types of links – hard links and symbolic links (symlinks) Every filename points to an “inode”, the absolute location of a file Linux allows different filenames to point to a single inode – results in a hard link Hard links share content and attributes – change one and the other changes as well A symlink is a redirect to the actual file (think shortcut in windows terms) It's a dumb pointer – you can link to nonexistent files, and you can link to directories ln creates hard links by default – use ln -s to create symlinks

14 locate Ubuntu creates an index of all of your files every night
locate command searches this index, as opposed to “find”, which searches recursively through each directory locate is much faster than find It's more limited than find as far as parameters – can't search by size, permissions, etc locate myfile.txt

15 Adv ls Lists files in current directory Switches
-a – includes hidden files -h – uses human readable sizes -l – uses long listing -r – uses reverse order -R – lists recursively -s – shows sizes of files --sort – sorts the listing by size/time/extension

16 tail tail can be used to view the last ten lines of a file
Mostly used to keep track of running log files – using -f parameter tail -f mylogfile

17 top Lists usage of resources Fields - PID – the process ID
User – the owner of the process PR – priority NI – niceness S – status %CPU – CPU usage %Mem – memory usage Time+ – CPU time Command – the command being run Etc Knowing a process ID allows you to “kill” the process

18 echo echo command At it's most basic it parrots text back at you
echo 'I am a wookie' will result in I am a wookie repeated on the next line Can echo the value of a system or env variable echo $PATH echo can redirect to a file echo 'I am a wookie' >> wookie.txt

19 End Chapter 11 We'll finish advanced command line next week
There will be lots of worksheets It may get frustrating Don't give up It takes time to get used to dealing with command line You don't have to be an expert in the first hour, day, week, month, year, etc

20 DOL and CCBY


Download ppt "Chapter 11 Command-Line Master Class"

Similar presentations


Ads by Google