Execute this command (lowercase LS):
This command shows files and directories in the current working directory, as shown below.
"ls" by itself isn't very useful, because it doesn't tell you much about the items. The next command is far more helpful.
Execute this command (lowercase LS -L):
This "long list" tells you a lot more information, as shown below.
The first character in each line is "d" for directories, or "-" for files. Towards the right, it shows the size of the file or directory in bytes and the date it was last modified, with the name at the far right.
My working directory contains only directories, no files.
If you want a brief summary of command options, execute the command followed by "--help". Execute this command:
A "brief" help page appear, as shown below.
Even that "brief" page contains far more information than I usually want to see. Most of those arguments are obscure and I never use them. My main source of help is actually Google.
Ooen a Web browser and go to google.com. Then search for
linux ls examples
You get a lot of really useful information, as shown below.
Go to this page and skim through the options to see some more ways to use "ls".
Execute this command:
This shows you a long, technical, and very confusing manual page about "ls" as shown below. This type of help is almost completely useless for beginners--it provides far too much information.
Press q to exit man.
Nano opens, as shown below. Nano is a very simple text editor, like Notepad without the mouse. Type in some text.
Notice the bottom of the nano screen--the available commands are shown here in a shorthand form.
Notice the lower left entry "^X Exit". This means that you can exit nano by pressing Ctrl+X. Press it now.
The next screen asks if you want to save the file. The bottom shows your options: Y, N, or Ctrl+C. Type Y.
At this screen, you can press Enter to save the file, or edit the name before saving it. Unfortunately, the list of commands at the bottom don't tell you either of those facts.
To see what you've done, execute this command:
There's now an entry for "file1", as shown below.
The result is "/root", as shown below. That's the directory we've been using.
Execute these commands. The first one makes a new directory, and the second one lists out the contents of the current working directory.
Now there's a directory named "proj0" in the working directory, as shown below.
mkdir proj0 ls -l
Execute these commands. The first one moves file1 into the "proj0" directory, and the second one lists out the contents of the current working directory.
"file1" no longer appears in the list, as shown below.
mv file1 proj0 ls -l
Execute these commands. The first one moves into the "proj0" directory, the second one shows the new working directory, and and the third one lists out the contents of the new current working directory.
This directory contains only one file, as shown below.
cd proj0 pwd ls -l
There's now a file named "file2", as shown below.
date date > file2 ls -l
Execute this command to open "file2" in nano.
The file contains the date, as shown below.
Press Ctrl+X to exit nano.
Execute these commands to display the contents of file1 and count.
The contents appear, as shown below.
cat file1 cat count
To search for a string in a file, use grep.
Execute these commands to display the lines in the file1 containing the string ab, and the lines in the file1 containing the string ab,
The matching lines appear, as shown below.
grep ab file1 grep a file1
You can use the -r switch to search directories and subdirectories recursively.
Execute this command find all lines containing a in the current directory and all subdirectories.
Don't omit the period at the end--that's called "dot" and it denotes the current working directory.
All matching lines in all files are found, as shown below.
grep a -r .
Enter this text, as shown below.
#!/bin/bash for i in 1 2 3 do echo $i done
Press Ctrl+X, Y, Enter to save the file.
This script should count from one to three. Execute this command to run the script:
An error message appears, saying "Permission denied", as shown below.
To see why this happened, execute this command:
Notice the beginning of the line containing "count" as shown below.
This line starts with "-", indicating that this is a file, not a directory. The next 9 letters are the permission string, using these letters:
The current permission string doesn't contain any "x" characters, so no one has permission to execute it.
Execute these commands to give execute permission to the "count" file for all users, and to see the new permissions:
As shown below, the file now has three "x" permissions, and the name turns green, to indicate that this is an executable file.
chmod a+x count ls -l
Execute this command to run the "count" script:
As shown below, the script runs, counting from 1 to 3.
As shown below, there are two adapters:
eth0 has an IP address (labelled "inet") and goes to the Internet.
lo is the loopback address and doesn't go anywhere. Your computer uses that address to talk to itself, which is useless for normal Web browsing.
Execute this command test your Internet connection:
As shown below, you should see "reply" messages, indicating that your Internet connection is working.
Press Ctrl+C to stop the pings.
If you move your computer to a new network, it might lose connectivity because it's still using an old IP address.
To fix that problem, execute this command:
As shown below, your computer sends out DHCPDISCOVER messages, and gets an IP address from the router.
dhclient -v eth0
Find your current working directory. That's the flag.
cd /tmp mkdir apple mkdir baker cd baker mkdir charlie
However, the script will not run:
What command will fix this problem? That command is the flag.
What command should be executed to fix the problem? 15 pts + 10 pts extra