Eric Brauer
Recall that Linux descended from an operating system designed for mainframes. That is, a single computer being used by many users simultaneously. In the 1980s, personal computers (PCs) became available, which as you can imagine was a revolutionary leap forward! In this case, you had one user working on one computer. Eventually DOS became the most common operating systems for these PCs, and Microsoft Windows was built on (and eventually replaced) DOS.
On Matrix, you have a space which is ‘yours’ for as long as you are a student. You have control over this space. On the other hand, there is a lot that you don’t have control over. The plumbing, the heat, the HVAC, and so on. There is an administrator/superintendant that has authority over these spaces, and who has permission to make changes. The super has authority to create, modify and remove user accounts.
These aren’t anything you’ll be tested on, but they will absolutely save you time. Please remember this: the shell is a place where accuracy is crucial. A typo will cause your command to not work, or to do something you didn’t want it to. The Tab key is an excellent way of troubleshooting. Here’s how it works:
Let’s go back to the previous example. You are in /home/student. You type in cd D
and then press tab once. You won’t see anything occur. You press tab twice. You should see a list of all the matching patterns, in this case both Desktop and Documents will be listed since they both contain D. You continue by typing in o
and press tab once again. Your path will be autocompleted, and you should see the complete command cd Documents
. Now you can press Enter to complete the command.
Please note that the auto-complete doesn’t unfortunately work when you’re working on Assignments. :( But in the real world, using Tab will speed up your work and also provide a ‘sanity check’ on your commands. If something should be auto-completing and it isn’t, 90% of the time it’s because you’ve made a mistake!
- Ctrl+a: Move to start of command
- Ctrl+e: Move to end of command
- Up & Down: Command History
- Tab: Autocomplete a Path (your first sanity check!)
- Ctrl+c: Cancel
- Ctrl+d: Logout
- Ctrl+r: Search your command history
- Ctrl+l: Clears the screen
ls
to view your home folder.cd public_html
to change your current location to public_html
.cd ..
to return to your home.pwd
to see your current location.The places outside your home folder are common spaces. You can see these places, but you can’t modify them.
cd /bin
to travel to one such location.ls
to view its contents.ls
in the contents of this folder.ls
is a program. And its location is in /bin
! So what would happen if a malicious person decided to modify ls
for everyone?
You don’t know it yet, but we’ve just demonstrated two different types of filepaths. To see how this works, let’s use a different type of diagram.
The rules for this ‘game’ are simple.
bin
.cd B
.B
only has one parent, we can save ourselves some typing by using ...cd ..
.cd aa
, and then press enter, and then enter cd B
. But this is a waste of time. Instead, we can enter: cd aa/B
.aa
and then moving into directory B
from aa
.cd ../..
.aa
before moving to B. This movement takes two turns.cd ../B
.cd ../../B
and it would take three turns.cd /B
.Note: There usually isn’t a /B in Linux systems, so try this with cd /bin
instead.
Compare the tree diagrams above with the output from tree
:
/
├── sample_dir
│ ├── faculty
│ ├── markham
│ ├── oxford
│ │ ├── programming
│ │ ├── report
│ │ └── security
│ ├── stenton
│ │ ├── gen_ed
│ │ └── lib_arts
│ └── todays-example
└── users
├── ebrau
└── sam
/
has two subdirectories (two dots)sample_dir
has five subdirectories.Please feel free to practice navigation by entering the following command:
cd ~eric.brauer/uli101
pwd
cd
ls
tree