LQ Poll: What's your favorite Linux terminal trick?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
My tips / tricks are basic dumb terminal tricks from around 30 years ago :
1. at night, instead of turning on the lights, I reversed the lighting on the VT100 so it was black on a white background instead of white on a black background.
2. I was getting a headache using a Wyse-50 in a room with North (sun) facing windows (without blinds) because of the brightness. I put on sunglasses (polarising type) and adjusted the screen brightness to compensate, and my headache went away.
That's a general tip : if you get a headache staring at a screen, try wearing sunglasses to cut the screen glare.
It's also part of the reason behind the health reccomendation of a 5 minute break every hour of screen use.
!$ to repeat the last parameter of the prior command line.
ls /foo/bar
vi !$/baz
can be very useful for a lot of file management commands. Works in Bash and in CSH, don't know if it works in Bourne (as if anyone uses SysV sh(1) in Linux)
This is helpful for a lot of things one normally has to wait for, like a DNS registration or even check the status or size of anything. It's a command to check if my expected output is ready or whatever it is.
Code:
watch -n1 "WHATEVER COMMAND I WANT RAN EVERY 1 SECOND"
Yeah, bash is fine, but I started Unix/Linux back in System-III times, when there were only sh and csh. And sh in those days was far from as fonctional as bash is nowadays, so developing in csh made a lot of sense.
Then came ksh, and posix-sh as extended versions for sh and in the same time tcsh to extend csh. Moving from csh to tcsh made a lot more sense than moving from csh to ksh. Not that all of this is from an end-user development working environment, not for system-scripts. csh/tcsh are *not* suited for portable system scripts.
So, where many users have (huge) custom settings for their favorite editor or IDE, many will also make good backups for their favorite shell startup file(s) (.profile, .bashrc, .tcshrc). Having an environment that works on all systems you work on (including old systems like AIX, HP-UX, Solaris and ancient versions of Linux that can not be modernized for dark reasons) my main production-booster command is to replace whatever the current shell on the system is with tcsh (and if I need to revisit the system more often, put .tcshrc in the home folder)
What's my favorite Linux trick? Not really a trick, but it is my favorite command line short-cut of all time... it's the "!$". Nothing saves more typing that !$. I can't live without it. If you've never heard of it, typing !$ on the command line repeats the last white-space separated <ANYTHING> from your previous command line. I love using !$ whenever the last thing I typed was so super long path or long filename. Why type it again? Simply hit !$. :-)
Yeah, bash is fine, but I started Unix/Linux back in System-III times, when there were only sh and csh. And sh in those days was far from as fonctional as bash is nowadays, so developing in csh made a lot of sense.
Then came ksh, and posix-sh as extended versions for sh and in the same time tcsh to extend csh. Moving from csh to tcsh made a lot more sense than moving from csh to ksh. Not that all of this is from an end-user development working environment, not for system-scripts. csh/tcsh are *not* suited for portable system scripts.
So, where many users have (huge) custom settings for their favorite editor or IDE, many will also make good backups for their favorite shell startup file(s) (.profile, .bashrc, .tcshrc). Having an environment that works on all systems you work on (including old systems like AIX, HP-UX, Solaris and ancient versions of Linux that can not be modernized for dark reasons) my main production-booster command is to replace whatever the current shell on the system is with tcsh (and if I need to revisit the system more often, put .tcshrc in the home folder)
YMMV
It was still that way in SysVr2 or r3 that I ran in a shell account before Linux, wasn't until SysVr4 that it got some BSDisms. tcsh is the default shell in FreeBSD I think, or at least the default csh. I'd run FreeBSD on my workstation sometimes except it doesn't support its hardware.
!$ to repeat the last parameter of the prior command line.
ls /foo/bar
vi !$/baz
can be very useful for a lot of file management commands. Works in Bash and in CSH, don't know if it works in Bourne (as if anyone uses SysV sh(1) in Linux)
Another shortcut that I like and getting same effect:
Code:
$ ls /foo/bar
$ alt+. # printing /foo/bar
Alt+. is repeating the last part of previous command, can be parameter, whatever.
from the mid 90s on, I've every now and then added to my, in .zshrc-sourced, ~/.zsh/completerc file which holds all my compctls.... many times I thought that I'd take the time and rewrite it to function with bash so I don't have to install zsh on every linux-host I login to ... but I'm to lazy to go through this mile-long file now and rewrite it ... it's just such a joy being able to hit tab almost anywhere on the command line and get the alternatives that makes sense for me in that exact position with the combination of commands that are currently typed ....
zsh's compctl is the joy of my terminal life :-D and my completerc-file is the hack of terminal hacks for me ... combined with surrounding functions and prepopulated data ...
e.g. my .zlogin does a 'host -l' of the zones I most frequently refers to hosts in and if it succeeds (I need to come from certain ip addresses to be able to do xfers of some of the zones) saves the hostnames in a file (otherwise it does not touch that file, as it already contains the hostnames from last time it succeeded) which then, via compctl, is used to complete hostnames in a number of commands such as ssh, rsync, etc, etc .... not having to type hostnames or ip addresses being able to simply tab-complete the correct FQDN when the hostname is the same in different domains/zones, etc, etc, is pure *joy* :-D ... being able to tab-complete every aspect of ip (iproute2) having it understand when you need to add a 'dev', listing the host's ifc names for you, etc, etc ... the possibilities are endless and have saved me so much time and effort over the years!
check out zsh's compctl ... or if you are a bash-person bash's 'complete + compopt' commands and tweak how you tab-complete ... it will make you a happier person by the end of the day :-)
Ctrl+U clears whatever text you just entered. This also works on password prompts (and also works in the password field on most lock screens I've used).
Most people have probably known about this for a while, but I just discovered it recently. I love it for password prompts because it saves me from hitting backspace an excessive number of times or Ctrl+C-ing out and re-invoking whatever program created the prompt.
I know it's very simple, but it took me a while to realise that I could copy and paste text to/from my terminal by using shift-ctrl-c and shift-ctrl-v.
Bit late in the day but SHIFT-INSERT also pastes into a terminal - SHIFT-DELETE will cut from Text Editor, I usually use these together SHIFT-DELETE - SHIFT-INSERT to put it back and then SHIFT-INSERT to put it where I need in a terminal.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.