This is my evaluation of Course III, Week 1 of the Google IT Support Professional Certification Course on Coursera.
. . .
Intro to the course, Becoming an OS Power User
Here we get the ubiquitous “I didn’t think tech was for me but oh wow through hard work and study I was able to learn and now I work at Google oh yeah I was a curious child also who liked computers” speech from our presenter, and then an outline of what this third course is going to be about.
We’re going to be learning the command line and Bash in Windows and Linux OS. This is the stuff from the movies, folks, so get ready to squint and try to figure out why your command isn’t working… was it one of the commas or something? Spelling is critical here, folks.
We are going to learn commands, package managers, process management, remote connection tools, and finally OS deployment.
“You need to really apply yourself to get good at it.”
Aw, I knew that was coming.
Lesson Overview and Practice Tips
We got a brief intro to Windows and Linux in Course I, so we’re just going to go crazy right now and start back in.
We are using the Windows GUI, which we are probably all disappointingly familiar with, as well as the CLI (Command Line Interpreter.) In Linux, we are only going to use the command line, which is called the shell, and you interact with it using a language called Bash.
Using the Windows GUI and a Linux GUI are very similar skills. But knowing Windows CLI will set you apart from many IT support techs (supposedly) and knowing the command line in any OS will help you become more efficient at your job.
This week will be broken into two main sections, the first about navigating the operating systems and the second about file and text manipulation.
Reading on CLI & Unix BaSH
Here is some documentation on PowerShell (POSH) for Windows and the “Bourne Again Shell” (BASH) in Linux.
I may skip over parts of the entire documentation for BASH. But only small parts.
List Directories in a GUI
Operating systems store information as files in directories. This is a hierarchical system, so there is one main directory that can contain many sub-directories, and so on. The location of a file is referred to by its path, meaning the location of that file in relation to all the directories “above” it in the file tree.
In Windows, a path looks like this:
“C:” is a drive letter, and refers to a drive, which contains an independent file system. A computer can have many drives, and Windows assigns them letters, such as D: or E: or F: etc.
Every file system has a root directory, which is the “parent” of all the other directories on the drive. It is as high up in the file system hierarchy as you can go, as all data is organized in it or in sub-directories of it. The root directory of the drive called “C:” is written as “C:\”
In Windows, subdirectories are separated by backslashes (\) and in Linux they are separated by forward slashes (/). This is just one of the really great things you’re going to have to remember because someone just had to be different.
A file path will always start with the root directory, and continues all the way through any sub-directories to the target file or folder.
We now watch as the presenter navigates (in the Windows GUI) from the root of the C: drive to her desktop folder, the patch of which is
Pretty exciting stuff. Did you know that in Windows file explorer you can go to the VIEW tab and check the “hidden files” check box and see all the hidden files in a folder? Yes, so did I.
To find some information about a file, you can right-click on a file and select “Properties.” This will show you the GENERAL properties tab, and includes file name, size, size on disk, the file path, the default program used to open that file type, time the file was created, time the file was last modified, and the time it was last accessed.
You can check the “Hidden” check box in a file’s properties to make it a hidden file.
We are skipping the SECURITY tab in properties. DETAILS shows some additional info about a file, including the option to “Remove Properties and Personal Information” which allows you to strip out some metadata about the file.
In the PREVIOUS VERSIONS tab you can (sometimes) revert a file to a previous version. I have never used this feature, but I am really good at not making mistakes in my files.
Back in Windows Explorer, feel free to change the view from Icons to List, or even Details! Wow!
Reading: “Size” vs “Size of Disk” in Windows
Going to start selling a “Size on Disk Matters” T shirt. Terrible.
Windows: List Directories in CLI
Windows features two command line interfaces, Command Prompt, cmd.exe, and PowerShell, powershell.exe. Command prompt has been around for a long time. PowerShell is newer and features most of the same commands as cmd.exe and also many commands, as aliases, for common commands in other shells. An alias is like a nickname, in this case.
Use the ls command to see all the directories in the C: drive:
PS C:\Users\Guy> ls c:\
The C: drive root folder is a parent directory and the contents are called child directories.
To see the parameters of the ls command in PowerShell, run the command
PS C:\Users\Guy> get-help ls
This gives you a fairly confusing list of words and punctuation that is all the parameters, I guess.
Use the command
PS C:\Users\Guy> get-help ls -full
To see a more complete list of confusing words and symbols. I hope we learn what this all means.
To see hidden and system files use the command ls with the -force parameter
PS C:\Users\Guy> ls -force C:\
Now, let’s take a look at the equivalent commands in Linux—–>
Linux: List Directories
The main directory, the highest in the filesystem, is called the root directory in Linux. Forward slashes (/) are used in Linux file paths, such as /home/username/Desktop.
Use the ls / command to list all directories within the current directory:
user@user-computer:~$ ls /
This will output a list of all directories in the root directory. Some important ones in the Linux machine used in this video are
- /bin contains essential binaries, or programs. This is similar to the Program Files directory in Windows. The ls command we just used is a program stored in the /bin directory.
- /etc stores important system configuration files
- /home is where user documents and data is stored. Like the Users directory in Windows.
- /proc contains data about current running processes.
- /usr contains user-installed software
- /var contains system logs and “basically any file that constantly changes.”
The ls command can be used with flags, which are like the command parameters in Windows, that is, they specify additional options for the command. Flags are usually used by adding a hyphen (-) and the flag option. You can view all available options for a command by adding the –help flag to a command:
user@user-computer:~$ ls --help
This outputs a lot of text, which you don’t need to memorize because it is built into the OS. It will list all the available options for the command specified. You may also want to see the manual by running the man command, like this:
user@user-computer:~$ man ls
This will show you a more detailed version of the – – help flag.
Here are some useful flags for the ls command:
- ls -l/ returns a “long list” of information (similar to Properties) like file permissions, number of links the file has, file owner, group, file size, last mod time, and directory name
- ls -a/ shows all the files in a directory, including hidden files. (To hide a file, prepend a “.” To the file name, as in “.secretHiddenFile”.
Windows: Changing Directories in GUI
This is done by clicking on a folder in the Windows Explorer. Yes, there is a whole video on this. It is short.
An Absolute Path is a path that starts from the main directory.
A Relative Path is from the current directory.
This is explained in the next video.
Windows: Changing Directories in CLI
PowerShell has a command to show you where you are, called print working directory, or pwd:
PS C:\Users\person> pwd
To change directories, use the change directory command, or cd, and add the relative or absolute path:
PS C:\Users\person> cd C:\Users\person\Documents
Above we used the absolute path, starting from the C: directory all the way down to the documents folder. But that may become a lot of typing when you get deep into directories, so there is a shortcut to move up one directory from your current directory:
PS C:\Users\person\Documents> cd .. PS C:\Users\person>
This put us back “up” in the “person” directory, one level above “Documents.” The “..” is a relative path because it will move you up one level from where you are.
To go from Documents up to the home directory, and then into the Desktop folder, we can add “\desktop”:
PS C:\Users\person\Documents> cd ..\Desktop PS C:\Users\person\Desktop>
Use the command cd~ (tilde) as a shortcut to the path of your home directory. You can then add the desired destination, like this:
PS C:\Users\person\Documents> cd ~\Desktop PS C:\Users\person\Desktop>
PowerShell has a feature called Tab Completion which allows you to start typing a file name or path, then pressing the tab key until your desired destination or name is shown. So, instead of typing “desktop” you can type “d” and press tab, and the rest of the word will be filled in.
A “.” before a directory means “current directory” as in “.\desktop\” from the home folder means “C:\Users\person\desktop”
Linux: Changing Directories in BASh
These are the same in BASh as in PowerShell:
pwd will print the working directory.
cd changes directories the same way, with absolute paths or by using a relative path, such as “../documents”
cd ~ references the home directory in BASh, so you can “cd ~/Desktop” will take you to the desktop directory.
There is also a Tab Completion feature, and it will list all the available options instead or auto-filling like in PowerShell.
Windows: Make Directories in the GUI & CLI
In the GUI, right click, select New, and select Folder. Then name the folder. That’s easy enough.
In PowerShell, the command is called make directory, or mkdir:
PS C:\Users\person> mkdir my_new_folder
This will make a folder called “my_new_folder”. If you do not want to use underscores but want to use the more readable, traditional spaces between words, you can’t simply use spaces in the command. You either need to enter the name in quotes:
PS C:\Users\person> mkdir ‘my new folder’
Or you need to use what is called an escape character, which is a method used in code to tell a program that the next thing (character or string) is not actually code but should be treated literally. The escape character in PowerShell is the back tick, (`):
PS C:\Users\person> mkdir my` new` folder
Linux: Make Directories in BASh
Again, this is the same command in BASh as in PowerShell:
person@computer:~/Desktop$ mkdir my_new_folder
The escape character in BASh is the backslash (\). [There is a typo in the video at this point—a forward slash instead of a backslash, making this a little bit confusing. You really can’t have typos in computer programming and command line instruction!]
person@computer:~/Desktop$ mkdir my\ new\ folder
person@computer:~/Desktop$ mkdir ‘my new folder’
Windows: Command History
PowerShell has a command which shows you all the commands you have entered in that session:
PS C:\Users\person> history
Usually, instead of actually using the command, you will just be activating the history feature by using the up and down arrow buttons which will allow you to scroll through the list of commands you have entered. Press CTRL+R to use a search tool that lets you search parts of commands you have used. In old versions of PowerShell you can use the # before a command (instead of CTRL+R) such as “#mkdir”.
Use the clear command to clear your screen of output. This does not erase your history.
PS C:\Users\person> clear
Linux: Command History
Use the same up and down keys to cycle through your commands. Use CTRL+R to search, and the clear command to clear your terminal app.
Windows: Copying Files and Directories
Copying files and folders in the Windows GUI is as simple as copying and pasting. Either using the keyboard shortcuts (CTRL+C to copy, CTRL+V to paste) or right-click and select copy or paste.
In PowerShell, the copy command is cp. You need the path of a file to copy and the path of a place to copy it to. The following command will copy “my_new_file.txt” from the Documents folder to the Desktop folder.
PS C:\Users\person\documents> cp my_new_file.txt C:\Users\person\Desktop
If you want to copy multiple files at once but don’t want to type them all out, we can use a character called a wildcard that allows multiple files to be selected based on a pattern, such as a file extension. In PowerShell we will use an asterisk (*) as the wildcard. Here we can copy ANY .jpg file from the documents folder:
PS C:\Users\person\documents> cp *.jpg C:\Users\person\Desktop\
To copy a directory, you use the same command as for a file:
PS C:\Users\person\documents> cp ‘Bird Law’ ~\Desktop
But this will only copy the folder called “Bird Law” to the Desktop and none of the contents. To copy the directory and the contents, you must use the -recurse command parameter. This means that the command executes for the top directory you are copying, then for any files within it, and repeats for any sub-directories. Here we are copying the “Bird Law” folder and its contents, and adding the -verbose parameter, which outputs a line for every file being copied:
PS C:\Users\person\documents> cp ‘Bird Law’ ~\Desktop -recurse -verbose
Linux: Copying Files and Directories
BASh uses the same commands as Windows for copying files.
person@computer:~/Desktop$ cp my_new_file.txt ~/Desktop
You can also use the same * wildcard to select all files with the same file extension.
You must also use recursion to copy the contents of a directory, which in BASh is -r.
person@computer:~/Desktop$ cp -r ‘Bird Law Folder’ ~/Desktop
Windows: Moving and Renaming Files and Directories
In the Windows GUI, right-click and select “Rename”.
In the command line, we use the move or move item commands. Move (mv) will allow you to rename something while keeping it in the same directory:
PS C:\Users\person\Desktop> mv .\blue_document.txt yellow_document.txt
Or you can actually move it to another directory:
PS C:\Users\person\Desktop> mv .\yellow_document.txt C:\Users\person\Documents
And you can move multiple files using a wildcard:
PS C:\Users\person\Desktop> mv *_document.txt C:\Users\person\Documents
Linux: Moving and renaming Files and Directories
Again, we can use the same mv command in BASh.
person@computer:~/Desktop$ mv red_document.txt blue_document.txt
Now move that blue_document into the Documents folder:
person@computer:~/Desktop$ mv blue_document.txt ~/Documents
Use the wildcard just like in Windows.
person@computer:~/Documents$ mv *_documents.txt ~/Desktop
Windows: Removing Files and Directories
I think we can all do this in the GUI without too much practice. Right-click, delete. That sends the file to the Recycle Bin. To restore the file, open the Recycle Bin, right-click the file, select Restore. If the Recycle Bin is emptied then those files are really gone.
In PowerShell the command to remove files and directories is rm for remove. Makes sense. This does NOT send the file to the Recycle Bin, but actually deletes them.
Remove a stupid text file that you hate from your home directory:
PS C:\Users\person> rm ~\stupid.txt
If you don’t have the proper permissions, or if a file is designated as a system file, you may get an error when you try to remove a file. This is so you don’t easily destroy your computer. If you are absolutely certain that you want to remove a system file, as long as you have adequate permissions, you can add the -force parameter:
PS C:\Users\person> rm C:\Users\person\critical_system_file -force
If you attempt to delete a directory that contains files or child directories, PowerShell is going to stop and check that you really want to delete the directory. You can either answer YES, YES TO ALL, NO, NO TO ALL, SUSPEND, or HELP, or you can add the recurse parameter to indicate that all contents of the directory should be deleted:
PS C:\Users\person> rm C:\Users\person\The_Folder -Recurse
It is always a good idea to be cautious when deleting files and directories.
Linux: Removing Files and Directories
The rm command is the same in Linux. I may be starting to notice a pattern. Use the -r flag to remove a directory and its contents/children.
Discussion: Your Favorite OS
I don’t remember what the first computer I used was. I know the first computer I was allowed to use had Windows 3.1.
Cindy: Why OS is Important
Here’s another video where our presenter explains why operating systems are important and that they can really do a lot. She works at Google and knows some smart people.
File and Text Manipulation
Windows: Display File Contents
Opening a file in the Windows GUI is probably a familiar process. Double Click! You can change the default program that opens a file type by right-clicking the file and selecting Properties, then clicking the Change button next to “Opens With:”.
PowerShell uses the concatenate command (cat) to view the contents of files.
PS C:\Users\person> cat .\important.txt
This is some important text regarding the importance of… oh, lets say… computers.
The cat command will default to displaying all the text in a file at once. To see text as one page at a time, use the more command:
PS C:\Users\person> more .\extra_large_file.txt This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. This this this this this. - - more - -
This will all you to advance to the next page, once you have read the first page. This is very helpful when you can’t read as fast a computer can type. The ENTER key advances the text by one line. SPACE advances by one page. (Page size is determined by your shell window.) The Q key exits the MORE program and returns you to the shell.
Use the -head parameter with the cat command to only see the “head” of a text file. Here we will see the first 10 lines of a file:
PS C:\Users\person> cat vegetables.txt -Head 10 Broccoli Carrots Onions Celery Cauliflower Potato Mushroom Something Something Something
You can also use the -Tail parameter to see the last lines of a file:
PS C:\Users\person> cat vegetables.txt -Tail 10 Moon Avocado Sea Rutabaga Future Beets Jail Celery Enchanted Cauliflower Drugs Potato Plain Mushroom Green Something Something About FIber Something Something
Linux: Display File Contents
BASh also uses the cat command to view a document, but instead of using the More command to view text in a manageable format, Linux has the Less command, which is similar to More but has, you guessed it, more.
person@computer:~/Desktop$ less large_doc.txt
This launches an interactive shell, like More in Windows, which can be navigated using the Up and Down arrow keys, and the Page Up and Page Down keys. A lower-case g moves to the beginning of a file, and uppercase G moves to the end of a text file. /word_search lets you search for a word or phrase within the file, just by typing “/whatever word.” And “q” allows you to quit Less and return to the shell.
Use the Head command to see the first ten lines of a text file:
person@computer:~/Desktop$ head books.txt Brains and Me I Love Sand This Book Sucks Another Book, the Sequel Why I Make Good Write Here You Go, Moron Buckets: A 3-D Adventure Story Book. Alone in the Sky (By a Bird) Book Finale: Why’d It Have To End
Use the Tail command in Linux to see the last ten lines of a text file.
Windows: Modifying Text Files
Notepad is the default editor in Windows for .txt files. We are going to use Notepad++ because of its advanced editing and syntax highlighting features.
Once installed, you can open Notepad++ from PowerShell like this:
PS C:\Users\person> start notepad++ afternoon.txt
Adding the filename will create a file called “afternoon.txt”.
Supplemental Reading for Notepad++
This reading is a link to the Notepad++ site.
Linux: Modifying Text Files
Nano is a popular and lightweight text editor that is found in most Linux distros. You can launch it from the terminal by entering nano and a file name:
person@computer:~/Desktop$ nano new_file
This launches the Nano editing window, at the bottom of which you will see several different commands, such as ^G or ^k. (The ^ means CTRL.)
Supplemental Reading for GNU Documentation
These are readings on the text editors Nano, Vim, and Emacs.
So far, we have been using some basic PowerShell commands. But PowerSHell has some advanced features, and we are going to look into that a little more.
A “real” PowerShell command that we used earlier was Get-Help, which showed us some information about a command. We have been using the ls command, which is actually an alias, meaning that it is representative of another command. Using the Get-Alias command we can see which command ls is using:
PS C:\Users\person> Get-Alias ls CommandType Name Alias ls->Get-ChildItem
This means that calling the ls command causes PowerShell to use the Get-ChildItem command, which shows all the files and child directories in the current directory.
Entering ls C:\ is the same as Get-ChildItem C:\
So this means we can use either the “real” commands or their aliases in PowerShell. We can also use the old cmd.exe commands, which have been incorporated into PowerShell. For example, PoSh Get-ChildItem = alias ls = cmd.exe dir. You can use the /? parameter in PowerShell to get help with cmd.exe commands.
Windows: Searching Within Files
Windows has a service called the Windows Search Service, which automatically collects and stores information about files. This is a resource-heavy process, so it is turned off in many servers, as well as outside the home directory in Windows Desktops.
Windows Search Service will help you find files based on name, file path, last modified, size, and some other details, but by default you cannot search for words within files. You can set this by opening Indexing Options from the Start Button/Search Bar. Then select the folder you’d like to select, such as Users. Click Advanced, and in the new window that opens click the File Types tab, and then you can check the box for “index properties and file contents.” This will reconfigure your Windows Search service to allow you to find words inside files from Windows Explorer.
Notepad++ also has a similar function, which can be accessed by pressing CTRL+SHIFT+F to open the “Find in Files” dialog box.
This can also all be done from the command line.
Here we use the Select-String command to find words or sequences of characters (strings) within files.
PS C:\Users\person> Select-String cow animals.txt animals.txt:1:cow horse duck
PowerShell found the word “cow” in the file “animals.txt” at line 1. We can also select all .txt files using the *wildcard:
PS C:\Users\person> Select-String cow *.txt animals.txt:1:cow horse duck barn_tenants.txt:2:cow, Robert
Here it found two instances of the word in two different files.
Windows: Searching Within Directories
If you want to search for something in a directory, such as all the .exe files, you can use the -filter parameter.
PS C:\Users\person> ls ‘C:\Program Files\’ -recurse – filter *.exe
This will output all the .exe files in C:\Program Files and all sub directories.
Linux: Searching Within Files
BASh has the grep command to search for words within files that match a pattern:
person@computer:~/Desktop$ grep cow farm_animals.txt cow chicken horse Jimmy
We can also search multiple files, by using the *wildcard on the file type:
person@computer:~/Desktop$ grep cow *_animals.txt farm_animals.txt: cow chicken horse Jimmy stupid_animals.txt: cow chicken Jimmy
Almost done, you’re doing grep.
Windows: Input, Output and Pipe
This video shows how we combine some of the commands we’ve learned so far.
PowerShell uses the alias echo for the command Write-Output. That means we can send text into a file:
PS C:\Users\person> echo bark > dog.txt
This just used the command Write-Output to put the word “bark” into the file “dog.txt”.
This is all made possible by something called I/O Streams. Think about all the information going in and coming out of a process as a stream. There are three streams for each process in Windows, Standard In (stdin), Standard Out (stdout), and Standard Error (stderr). You input data to the process using the stdin stream, and the process creates output and sends that out the stdout stream. A keyboard puts data into the stdin stream of whichever process you are interacting with.
The ”greater than” symbol > is something called a redirector operator, which allows us to change where the stdout stream goes. That’s what we did above, adding the word “bark” to the file dog.txt, instead of writing it to the screen. If we use >> it will work similarly but will not overwrite existing files.
If you want to send the output of one command to be the input of another command, we use the pipe operator (|). Here we start with a list of words “street tree blast last”. The following command will show us a list of all the words with the string “st”.
PS C:\Users\person> cat words.txt | Select-String st Street Blast Last
This took the output of “cat words.txt” and “piped” it into the input of sls. Here we can do the same thing, and redirect the ultimate output to a new file:
PS C:\Users\person> cat words.txt | Select-String st > st_words.txt
Earlier, we got an error message when trying to delete a protected system file. This error proceeded through the stderr stream, and can be redirected using the “2” redirection operator.
PS C:\Users\person> rm the_secure_file.txt 2> error.txt
The numeral 2 indicates the output stream being redirected to error.txt. 1=stdout and 2=stderr. A simple > indicates that the stdout should be redirected, and a 2> indicates that the stderr output should be redirected.
If we have no interest in the error messages being generated, then we can redirect them to a special variable called $null.
PS C:\Users\person> rm the_secure_file.txt 2> $null
There is still way more to learn, so feel free to try
PS C:\Users\person> Get-Help about_redirection
Linux: Input, Output and Pipe
Linux features the same stdin, stdout, and stderr I/O streams as Windows. We can use the same echo > redirection as in windows, and >> when we don’t want to overwrite anything if a text file already exists with the name we have specified.
There is also a stdin redirector operator, the “less than” sign <. This takes input from a file and uses it in the stdin stream.
Linux also uses the 2> redirector for the stderr stream.
In Windows we used the $null variable to filer out unwanted stderr output. In Linux there is a /dev/null folder that is used for this purpose.
Windows and Linux Advanced Navigation
We are going to learn some more advanced command line functionality. Regular expressions are used for advanced pattern-based search. That’s an example of one. Okay.
Supplemental Reading for Windows PowerShell
Some additional info on getting into PowerShell HERE and HERE.
Ben: First Tech Job
This guy convinced a store owner to buy a computer and have him program it. He was a child. The job lasted eleven years.
>>>>>>>>>Create, Modify, and Remove Files and Folders in Windows>>>>>>>>>
The system they have in place to give you access to virtual machines is completely stupid and unnecessarily complicated. You must first launch “quiklabs,” (whatever the hell that is) out of the Coursera platform, then launch a console session from there. Then you have to sign in through the google account portal with a given temp account. Then you have to agree to ToS and answer another stupid question, then, finally, you can see your VM instance, which, if it is a Linux VM, you simply click SSH and log in with the auto-filled google account creds. But the Windows VMs have to be RDP’d into, and you can’t use the account info you got to log into the VM platform from Quiklabs. You have to change the name to “student.” If you don’t do this, you are supposedly not going to get points for the exercises. But, it turns out, you can get two-thirds credit (In my case today there was one broken question) That means you can get 66%, which is a failing grade. This course is 80% to pass. So if you sign in incorrectly you may still be getting some points, although not enough to pass, and it would not indicate that you signed in incorrectly.
So go through and do the stupid exercise six times just to make sure. The sign-in/loading process takes about five minutes. Oh look, your only day off is now over because you just had to prove to Google that you can create a fucking folder and text file.
Just as a reminder, I am paying money for this course. It seems like navigating some byzantine 4-party VM ecosystem is a skill-mismatch with someone looking to certify that they can create folders in a GUI.
>>>>>>>>>>>Create, Modify, and Remove Files and Folders in Linux>>>>>>>>>>>
Here’s my beautiful terminal session in my easy-to-open Linux VM:
Great week, everyone, see you in Week 14!
The Hapless Rube's Apocalypse Survival Guide | by Jack Barker Homer's Odyssey | Translated by Norbert A.D. Albertson | Paperback WD Elements 2TB Portable Hard Drive USB 3.0
One thought on “Google IT Cert – Week 13 – Becoming an OS Power User”