Get Familiar with the Linux Command Line
Want to be a superuser? Mastery of the Linux command line is attainable, and it will open the door to computer powers you could only dream of otherwise. Ever see a person in real life or in a movie typing commands onto a black screen - no GUI, no pretty interface - and think, "that guy must be a hacker"? Do you want to be that person? You can. The trick is getting a start, and NOW is always the best time.
If you are a Mac or Linux user, go ahead and open the terminal. Trust me, it's already installed. If you're a Windows user, click the Start Menu icon on your taskbar, type "powershell", and press Enter. Into the Powershell terminal, type:
wsl --install -d Debian
After hitting Enter, Windows Subsystem Linux distro Debian will install. Go ahead and restart your computer for good measure. Once restarted, click the Start Menu icon and type "debian" and press Enter. Boom!
Now, everyone has an open terminal. Windows users, you will be asked to enter a username and password. Do so and remember it or write it down! Mac and Linux users will use the username and passwords used to log into your machines. Type the following command and press Enter to make sure everything is up-to-date.
$ sudo apt update
The sudo command temporarily gives your user superuser permissions to install packages and run sensitive commands. Be careful with sudo! With great power...
After the updates complete, type the following command and hit Enter.
$ cd ~
cd = "change directory" and ~ represents your home directory. No matter where you are in the file structure, typing this command will take you back home. There's no place like home!
To list the contents of your home directory, type the following command and hit Enter:
$ ls
ls = "list". However, there may be nothing in your home directory yet (that you can see!). Let's add an option to the ls command. Type the following command and hit Enter:
$ ls -a
Well, I'll be. There is something in there after all! Notice the periods before the filenmanes when running `ls -a`. These are hidden files. The .bashrc file configures the behavior of your terminal session!
To look at the contents of .bashrc without having a chance of messing up it's contents, run the following command and press Enter:
$ cat .bashrc
The `cat` command outputs the contents of a file to the command line. For now, don't worry about the nature of the contents of .bashrc. You'll come to understand this later as your powers mature!
Let's create a directory named SCRIPTS. As you become more familiar with the power of the bash shell, you're going to want to write scripts. Run the following command:
$ mkdir SCRIPTS
Now:
$ ls
How about it?! Now, you've made something. Go ahead and `cd` into the new folder:
$ cd SCRIPTS
Now:
$ ls
Of course, it's empty. This directory is brand new!
Run the following command:
$ echo "Hello World!"
The `echo` command outputs text to the terminal. Let's redirect the output of the `echo` command to make a file using `>`. Run the following command:
$ echo "Hello World!" > hello-world.txt
Note that it's best practice not to use spaces in Linux filenames! Now:
$ cat hello-world.txt
Well, gosh dang! Cooking with fire now. How can we make a file without the `cat` command and redirection? We need an editor!
Learn vim! Run the following command:
$ sudo apt install vim
After the install is complete, run the following command:
$ vimtutor
Read through and complete the tutorial! Wait until your comp sci professors find out you know vim! You're a rockstar. See you in the next tutorial.
Check out Wicked Cool Shell Scripts below!