Sunday, April 19, 2015

LXTerminal Cheatsheet

LXTerminal is daunting for the beginner. It can feel like a big black hole. Using a few basic commands everyday will help you learn the ropes. Lets take a look at the easy ones.
Displays the current directory path.
Displays the directory and files within the current directory.
cd /home
Changes the directory, but needs a target and at least one /. This is the first time you will note that capitalisation is important in Linux. /home and /Home are two different locations.
Some help that was, it blew right by so fast I couldn’t read it. We will fix that shortly.
mkdir exampleMake a directory.
Displays a calendar.
Displays the current date and time.
gedit filename.txt
Opens gedit with the file name in question. Be aware that you cannot close the terminal while gedit is open.
command > filename.txt
The > character tells the terminal to send the text that would normally appear on-screen to a file. The file can either be one that exists, in which case the text in it will be replace with the current text. Alternatively, you can make up a new name and write to that new file.
command >> filename.txt
A double > or >> will append information to the end of the file in question. Oddly, if that file does not exist the console will create it for you. Handy, eh?
command | tee example.txt
The pipe, | and the modifier tee will tell the terminal to print the information on-screen and to a file.
There are three more pseudo commands you need to know. The up arrow will display the last command you entered, you can do this to hop backwards through every command you entered. Of course, you will overshoot the one you want. Down arrow goes the other direction. To paste text into the terminal, press shift ctrl+V. Ctrl+V on its own does nothing.
So, let’s make a cheat sheet for this lesson. Open the LXTerminal.
Enter pwd to check that you are in a safe directory. For Mint that is /home/.
Enter ls to view the contents of /home/name.
Type mkdir cheatsheet.
Go to that directory with cd cheatsheet
To rehash:
mkdir cheatsheet
cd cheatsheet
From here on out, I will not explain in detail. Each command will be entered one after the other. Remember to press enter after each.
cal | tee >> cheatsheet.txt
date | tee >> cheatsheet.txt
pwd | tee >> cheatsheet.txt
ls | tee >> cheatsheet.txt
help | tee >> cheatsheet.txt
gedit cheatsheet.txt
Now you have your own cheatsheet. Go ahead and print it.
Extra credit assignment. You can paste all the above commands into the terminal at a single go. The terminal will execute them as if you did them one by one.
More LXTerminal usage to come. Enjoy.