Cool Shortcuts

Rob

Administrator
Staff member
Who doesn't like shortcuts? Well, the answer is my wife. But only because my shortcuts usually double the length of our trips... Anyway, if you are going to spend any time in the Linux command line interface, I highly recommend learning a few easy shortcuts that will make your life MUCH easier!

Auto Complete Anything You Type!

One of the best shortcuts is the auto-complete feature in Linux. Just start typing the name of a file, directory or program and then hit <TAB>.

ls m <TAB><TAB><TAB>
Then push the <TAB> key. Linux is going to beep a couple of times, but you keep pushing. You will now see every file in the directory that begins with the letter 'm'

Now add an 'o' on to `ls m` so you get `ls mo` - now push the tab key.

ls mo <TAB>

You should see 'motd'. This is a file that contains your startup message. SuSE has a famous one that says 'Have a lot of fun!'. I like that one so I haven't changed it, but you can change it so that Linux says anything you want when you log in.

Linux Saves Everything That You Type In Your History File!

Do you want to make sure that lilo.conf is still in there? You don't have to type 'lilo.conf' or even part of it and press the tab key anymore. You just have to press the up arrow. Your last commands will appear when you do that.

Your commands are saved in a history file located in your home directory. The more times you press the up button, the farther back in time you go. Pressing the down button gets you back to your most recent commands. Just stop on the command you want and press 'enter'. You can even type the command history and all of the last 400 or so commands you've typed will be presented. As you get more proficient in Linux, you'll find that thisreally comes in handy. You can often find out the answer to the question: How did I do that? by consulting your shell history.

The /usr directory

Let's talk about using some options with commands.

Code:
cd /usr
this will take you to the /usr directory

Code:
ls -l
This will give you a more detailed view about the contents of your current directory, which happens to be the /usr directory.

You will see more information, like dates, some numbers, letter combinations. It will say 'root' a lot. We'll get into more detail about what all of that means later in the course. You'll see mainly sub-directories here. The usr/ directory contains files and programs meant to be used by all of the users on the system.
 


dos2unix

Member
bash history is cool too.

if you type "history" , you'll get an output of the command you've typed in the past.

....
719 free -mh
720 lshw -class disk
721 lshw -class net
722 netstat -nr
723 cat /etc/resolv.conf
724 exit
725 uname -a
726 nmcli con up eno1
727 glances
728 df -h
729 exit
730 cd /home/fido/playbooks/
731 ls
732 cat generic_linux.yml
733 vi hosts
....

dont like typing the same commands, you can eith press the "up arrow key" a few times to get back to that command, or else you can just type

!723

to cat that /etc/resolv.conf again.

Obviously your list will be different, but just use !(command number)
 

arochester

Moderator
Staff member
Gold Supporter
¿Qué tiene que ver esto con los atajos? Por favor, no agregue su pregunta a un hilo. Comience su propio hilo.

What has this to do with shortcuts? Please don't just add your question onto a thread. Start your own thread.
 

Members online


Top