We have recently covered how to get around in the Linux terminal, change directories, move and rename files just to name some of the tips. Today I wanted to get into some extra tips about the terminal that you may or may not be familiar with.
Whenever you're working in the terminal, remember that there is a maximum filename length for any given file. You'll run into problems if you're so descriptive you need more than 255 characters, but lets just hope that isn't the case! Anything less than 80 should suffice and keep your filename from wrapping. Filenames are also case sensitive. So if I wanted to move Pic1.jpg, I'd have to make sure that the P in Pic is correctly uppercase or lowercase to match the file in question. Like all OS's, there are certain characters that can totally confuse the heck out of the shell, and you'll want to avoid those when naming files. Using a (forward slash)/ in the middle of your file name will make it think you're trying to save a file into a directory. For example, rm Pineapple/Guide.jpg would try to remove a file called Guide.jpg in the Pineapple directory.
As mentioned in a previous HakTip, spaces can confuse the shell as well, so instead, bunch words together in your filename, use quotation marks around the filename, or place a backslash after each word in the filename. Ex. file called Pineapple Guide.txt would have to be written as "Pineapple Guide.txt" or Pineapple Guide.txt. After the break, lets look at some history shortcuts.
One neat thing about the Terminal is you can view your history of commands, up to 500 lines. So if you've been moving and renaming files for the past hour and want to run the same command again, you have a few options. History is a command that will show you each line that has run up to 500 back. Want to look at them one screen at a time? Type history | less, to use the less program which will let you view each page of commands one at a time. Want to just run the last command you did? Type !! and terminal will do it for you (or type !499, which will rerun history line number 499). You can also press the up button on your keyboard a few times to find a recently used command. You can always go back to a command and retype it as well if there was a mistake, or press tab to have it auto complete for you if you're using long filenames.
How did you learn the terminal? Got a favorite book, website, or did you learn it all on your own? Tell me about it in the comments or email me at email@example.com. And be sure to check out our sister show, Hak5 for more great stuff just like this. I'll be there, reminding you to trust your technolust.