Linux is an essential part of the class, so it's important to get some experience with this before working with the robots. Although you're encouraged to collaborate with others if you are stuck, the lab should be completed individually so you can get practice with skills that will be essential later on in the course when you are in teams. If you have general questions, please post on Piazza so other students can benefit from the answer. If you have a question about your individual submission, please make a private post. Make sure you're using an Debian terminal if you're testing the commands. Instructions for setting up the course software is here. Alternatively, you can use your athena terminal to test commands by typing ssh athena.dialup.mit.edu -l <kerberos>
in your terminal although some commands may not work.
In order to get credit for this assignment, you will submit a .zip
file to Gradescope under lab1a_exercises_linux. The format of the file will be specified in question 4. Your submission will not get graded properly if you don't put it in the right format. This lab is due on February 13th at 1:00PM.
If you don't have previous experience with linux, we recommend that you read the following tutorials by the Software Carpentry Foundation before starting on the exercises. Otherwise, you can just use the resources as you need.
- Setup
- Introducing the Shell
- Navigating files and directories
- Working with files and directories
- Pipes and filters
- Finding things
- Clone this repository by typing
git clone https://github.com/mit-rss/intro_to_linux.git
into your terminal - Place your answers to 1-3 in
linux_exercise.txt
. Every command should go between the #####<question_number>####### and #####End of Question####### lines - During this class, you will need to be familiar with at least one terminal-based text editor like vim, nano, emacs. We recommend getting some practice with a terminal-based text editor when you're editing
linux_exercise.txt
. - Run
sanity_checker.py
to double check that your answers are correctly formatted - Provide a single command for each of the following questions. If multiple answers are possible, choose the shortest answer. All of your commands should work regardless of your current working directory. Hint
- Continue onto question 4 to find out how to submit your answers
The first thing you need to learn in the command-line is how to navigate the filesystem and view the contents of directories and files.
1a. Navigate to your home directory
1b. Navigate to your root directory
1c. Navigate to the parent directory of your current directory
1d. List all the files/directories in your home directory, including hidden ones, in long listing format
1e. Print your current working directory
One of the awesome features of UNIX-based operating systems is how simple it is to install programs through the terminal. For this question, use apt.
2a. Install a program called inxi
.
2b. Open up documentation for inxi
in the terminal to see what it does. Hint
2c. Use inxi
to show basic information about your Audio/sound card without extra information
2d. Uninstall inxi
2e. Open firefox using the terminal
2f. Update the list of available Debian packages
2g. Upgrade all existing packages
Another cool feature that you will be using often in this class is SSH, which enables you to access the terminals of other Linux-powered remote devices or systems as long as you have access credentials. This is how you will access the racecars.
3a. Log into a remote shell with the IP address 192.168.0.101 and username "racecar". This probably won't do anything if you try to run it now.
3b. Exit the ssh session
3c. Using the scp command from your local terminal, move the file at path ~/Documents/image.png
on your native machine into the folder ~/Pictures
on the machine in part a. This is useful for transferring files between your computer and the racecar.
3d. Add an alias to the end of your ~/.bashrc
file that runs ls -alF
when you type ll
. The .bashrc file is executed every time you start a new shell, so this allows you to create shortcuts for longer commands. You can test your command by typing source ~/.bashrc
and typing ll
.
Now that you're familiar with the basics of the command line, complete the following exercise in order to get credit for this assignment. In this exercise, you will be reorganizing the .txt
files found in the lab1/
directory. In addition to the commands introduced in questions 1-3, you might find grep
, |
, >
, >>
, awk
, sed
, mkdir
, rm
, wc
, cat
, cut
, zip
, sort
, for
, etc useful. We encourage you to work incrementally, use the internet as a resource, and write down commands that are helpful as you go.
Please perform the following modifications to the lab1/
directory:
- Any file with the extension
.txt
that does not contain 10 lines is corrupted and should be deleted from the whole directory. The names of the files that are deleted should be written in a file calleddeleted_files.txt
with 1 filename per line in ascending numerical order. - Out of the remaining
.txt
files with 10 lines, the ones that contain the string "IMPORTANT" should be placed in a new directory namedimportant/
. The rest of the.txt
files should be placed in another new directory namedunimportant/
. - After reorganizing all the
.txt
files, add the file namedlinux_exercise.txt
that contains your answers to questions 1-3 into thelab1/
directory. - Zip the folder into a file called
lab1.zip
As a summary, the final zipped folder should contain the following:
*linux_exercise.txt
*deleted_files.txt
*important/
*unimportant/