Welcome
Hi, and welcome to my little tut on the linux terminal. I'm not even close to being a pro, so I apologize in advance if I mess up. I'm writing this tutorial with Ubuntu 10.4 Lucid Lynx.
Commands sent to the console will have aWhatever the terminal shows/spits out will be in italics.quotation box
I'm not sure why, but most *nix beginners tend to stay away from the terminal (I did, anyway)! But hey, you'll learn that its not that bad after all.
Getting Started
Ok. To get started, goto: Applications -->Accessories-->Terminal.
Now, a terminal will pop up. It's easy to get intimidated, but don't get scared—it's easy. You should see a blinking cursor. Before that cursor, you probably see:
yourName@ubuntu:~$
Our first command
Let's try something simple. TypeGood job! You just completed your first command in the console! (it wasn't that bad, right?)pwd
After typing “pwd”, you'll see that the terminal says something. It should say:
/home/yourName
This represents where you are. When you navigate graphically, you click, right? You double click on the folders that you wanna go into. Similarly, you move around in the terminal by issuing commands to the console. Let's try another.
ls and hidden files
Type:Your terminal should give you (most) of the folders/files that it can see in /home/yourName. For me, it has stuff like:ls
Desktop Downloads Music Programming Videos Documents
…etc
However, we're not seeing the whole picture. Some files are hidden! To see those, type this:
Whoaa! My whole screen filled up with more items! You should see stuff like .compiz, .evolution, .gconf, .mozilla, .bash_history, .bashrcls -a
…..etc
Text Editing!
Let's edit .bashrc. There are two ways to play around with this file. Let's first try vi/vim. Type
(note: if this doesn't work, type vi .bashrc)vim .bashrc
Now, you'll see some REALLY random stuff! All you are seeing is some code in bash. The weird thing about vi/vim is that you can't edit right off the bat (wouldn't recommend anyway, lol). Try it, if you don't believe me! Type f, or g, or h. Nothing happens! This is because you are in command mode. To edit stuff, you have to be in insert mode. Type “i” to enter insert mode. Now you can edit stuff. Anyway, don't be discouraged if vim feels weird. I'm learning it too. To exit insert mode, press Escape. Ok. We are going to quit without saving changes. To do this, typeAfter you type the semicolon, you should see what you type in the bottom left corner, like this::q!
Press enter. This will quit the file you were editing without saving any changes you made. To save changes, you would typeIf vim intimidated you, don't worry! There's nano too. Try this::wqYou should be more comfortable. You can move around and edit from the beginning. It's a lightweight but powerful text editor. To quit, simply press Control-X. If it asks if it wants to save changes, just hit N for “no.” See? Nano aint that bad, right?nano .bashrc
Shortcuts and Autocompletion
Let's play around some more with the terminal. TypeYou know this command. It shows the files/directories you can access. Now, we will change directories with the cd command. TypelsYou'll move into the Downloads folder. Check if you've really gone into it by typingcd Downloadsagain. Does it look different? Nice! You've successfully changed directories! Let's go back to the previous folder. We can do this the fast way or the slow way. Let's do it the slow way first. TypelsThis'll transport you back to where you where. Ok let's go back to Downloads. Typecd /home/yourNameOk. Now, typecd Downloads.(two dots). And... you're back to your previous directory. Pretty cool huh? There's also a quicker way to go to the Downloads folder too. Ok. Type this:cd ..What this command does is create a directory with the name that we provided. It's pretty disgusting, huh? Sometimes, you'll get files that are just plain annoying to type. So, there's something called autocomplete. Typemkdir gooper_hash.99_pzxxsto make sure that the gooper directory exists. Ok. Now, type "goop" (w/o quotes) then press Tab. Then boom! The terminal should do all the work for you. Awesome, right? Ok, so, to go to Downloads (make sure that you are at /home/yourName), typelsthen press Tab. It should autocomplete.cd Dow
Wrapping up with something fun :laugh:
The terminal is fun, no? Ok. Let's wrap up with something fun! Let's say that you're torrenting (or whatever) and you want your computer to shut off at 3:30 in the morning to save electricity after Dling/seeding for a couple hours. You can do that in the terminal easily! TypeReplace "timeInMinutes" to how many minutes you want your machine to wait until shutdown. So, if its 12:00AM right now and I want a shutdown at 2:30AM, I would typesudo shutdown -P timeInMinutesThe "-P" flag will tell the computer to power off. If you typedsudo shutdown -P 150your computer will restart in 5 minutes. The terminal will then prompt for your pass. Simply type it in. I really hope I did the math right. Please correct me if I'm wrong (the 150 minute one).sudo shutdown -r 5
Fin
And that's it! You have successfully mastered the basics of the terminal! Congrats!
:laugh:









LinkBack URL
About LinkBacks


Reply With Quote




