Cool Shortcuts

Rob

Administrator
Staff member
Joined
Oct 27, 2011
Messages
1,210
Reaction score
2,240
Credits
3,485
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.
 


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)
 
me pueden recomendar que distribuidor de linux es mejor para poder utilizar rdp
 
¿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.
 
fc let's you edit your previous command in a Vim buffer. I find this immensely helpful when I mistype a complicated command, which happens often.
 
Don't forget about bash aliases. You can make any command an alias.
Just create .bash_aliases
For instances I use Gomuks for Matrix, so I put this in my aliases:
alias gomuks=/home/pi/Downloads/gomuks-linux-arm64
Now all I have to type is gomuks in a terminal and it opens and connects to Matrix.
 

Members online


Top