1.1 Some New Commands
I didn’t go too in depth with this as you probably won’t be touching the command line anytime soon after week 1 (i.e., you’ll have your hands full with Python pretty soon)!
However, I still did introduce a few new commands that I think may come in handy if you ever have a need for the Linux command line in the future!
These are:
echo
If you have served your two years of National Service, you may have sang a verse that went something like this during a road march (apologies if I got any of this wrong - I didn’t march during my two years):
Sergeant: “Echo after me lah!”
Everybody else: “Echo after you lah!”
(verses begin)
– Every sergeant and his platoon (?)
And this - in essence - is what
echo
does. It essentially repeats everything that comes after theecho
. For instance,echo My name is Kevin
would displayMy name is Kevin
to the command line!sudo
“sudo” is actually an acronym that stands for super user do. A super user is a computer user who has a wide range of capabilities (e.g., accessing system files, changing other users’ login credentials, assigning root privileges to other users, etc).
The
sudo
command is used as a prefix of some command; it is used to run commands with root privileges. For instance -sudo gem install rails
tells RubyGems (i.e., Ruby’s package manager) to install the rails gem off the rubygems repository. Here, I am usingsudo
as root privileges are required to install gems (i.e., packages) usinggem install
!mv
mv
is short formove
. As its name suggests,mv
is used to move files and directories from one location to another. One can do so as such:mv <file name here> <new location here>
.Yet,
mv
can also be used to re-name items. To do so, one can do something along the lines ofmv <old name here> <new name here>
on the command line!help
Unsurprisingly, Linux’s command line has a
help
function in case you ever forget what a command does. I forget stuff all the time, but if there’s one thing that I would recommend you to remember, it’s this command!To view the help files for a command, type
help <command name here>
on the command line.>
This is called the redirection operator. It directs the output from the command on the left to the command on the right.
If you remember, I typed something like
echo Nothing > breakfast.txt
during the tutorials. What was I doing?I first
echo
ed “Nothing” (because I skept breakfast) and using the redirection operator, sent “Nothing” to a file calledbreakfast.txt
. When you use>
, your machine (or Colab rather) will create a newbreakfast.txt
if there isn’t already one. Otherwise, the previousbreakfast.txt
will be over-written!