r/UnixProTips • u/noreallyimthepope • Feb 05 '15
r/UnixProTips • u/Aihal • Feb 05 '15
moreutils
There's a useful collection of little cli helpers called moreutils, as a play on coreutils obviously.
The most useful one for me is vidir which let's you edit the filenames supplied (or if no argument the current directory) with your EDITOR. So if i do mass renaming i can do it in vim. <3
r/UnixProTips • u/the-fritz • Feb 12 '15
[bash] Extended Globs: Advanced pattern matching.
Bash supports extended globs, for more convenient pattern expansion. You have to enable them using
shopt -s extglobThen you can do fancy things like get all files that do not match a specific pattern. E.g., all files that do not end in .bu:
ls !(*.bu)The following additional patterns are available
?(PATTERN-LIST)Matches zero or one occurrence of the given patterns.*(PATTERN-LIST)Matches zero or more occurrences of the given patterns.+(PATTERN-LIST)Matches one or more occurrences of the given patterns.@(PATTERN-LIST)Matches one of the given patterns.!(PATTERN-LIST)Matches anything except one of the given patterns.
and they can of course be nested.
See
for more information. To disable them again use shopt -u extglob.
r/UnixProTips • u/rdeker • Feb 04 '15
Use Control-t in bash to fix a typo
It's a simple but I find often unused bash shortcut. It swaps the two characters to the left of the cursor. For example, if your fingers get crossed typing "sudo"
foo@bar:~$ suodJust mash Control-t and it's magically
foo@bar:~$ sudoFor bonus points, use Alt-t to do this with the last two words too
r/UnixProTips • u/Wes_0 • Feb 05 '15
Fast switching between two locations: "cd -"
"cd -" allows you to go to the previous location you were. For instance:
cd ~/Desktop
cd ~/long/complicated/different/path
cd - #you are back in ~/Destkop
cd - #you are back in ~/long/complicated/different/pathr/UnixProTips • u/07dosa • Feb 05 '15
Ctrl + z = SIGTSTP
This is the ultimate trick you need for your everyday use of terminals.
Pressing Ctrl+z sends SIGTSTP to the current foreground job, and this causes the process to suspend in the background without losing any data, kicking you back to the shell. This allows you to, for example, suspend Vim for a while to check some other stuffs in the shell while remaining on the same terminal.
To bring suspended jobs back to the foreground, type fg in the shell. More details can be found in "Job Control" or "Jobs" section in the manpage of your shell.
r/UnixProTips • u/pie-n • Feb 06 '15
Need to post code on reddit? You want to prepend 4 spaces?
I know RES will do this for you, but if you don't use it and want it for yourself here you go.
sed 's/^/ /' file | xclip -sel c
Note the second part of that sed is four spaces, and you can use whatever clipboard you ave installed.
r/UnixProTips • u/AMDmi3 • Feb 26 '15
Quick set operations
If you have two lists of strings (for example, file names) and you want to get strings that are present in the first list, but not in the second, a quick way to do it is:
cat list1 list2 list2 | sort | uniq -uOther set operations are possible by duplicating another list contents and/or using uniq -d.
Of course, it is more correct and efficient to use comm(1), but the suggested way doesn't require lists to be pre-sorted and allows processing of pipeline and command outputs without need of intermediate files.
r/UnixProTips • u/Bobbbay • Jan 13 '21
UPT Pro Guide
Unix is our favorite child. Flexible, applicable, customizable- wait, did you say customizable?
(this post is a work-in-progress, all recommendations accepted in the comments)
Vocabulary
POSIX-compliant: Being POSIX-compliant for an OS means that it supports those standards (e.g., APIs), and thus can either natively run UNIX programs, or at least porting an application from UNIX to the target OS is easy/easier than if it did not support POSIX. [superuser]
Shells
Bash: the default shell on most installations
Zsh: spelling correction, automation, and better plugin management
Fish: the non-POSIX oriented shell
Getting Help
IRC Channels:
#vim, #emacs
Discord servers:
Vi-tality, the vim and other things oriented server.
r/UnixProTips • u/Bobbbay • Jan 13 '21
Shell UPT of the Day: Modify your HISTCONTROL to have "ignorespace" to ignore all commands that start with a space in your history.
I find this super useful if you're entering a password or key in some command. Furthermore, I've heard that a lot of containerized package managers still give read access to your home directory - so in theory, all these applications have access to your whole history.
Bob.
r/UnixProTips • u/loadedmind • Jul 14 '15
Closing idle sessions per user
Our environment consists of CentOS and we have 5 login nodes (blades) that load balance for approximately 150 users via OpenLDAP authentication. We're noticing that folks are leaving sessions opened for as much as two months at a time, but they use these login nodes for a jumping off point to other blades where they can kick off such things as Matlab, gdb, ddd, etc.
We're having to reboot these blades from time to time because the firefox, NX and other resource-intensive programs yank too much CPU/memory and they end up becoming unresponsive. Probably a memory leak within the program(s) they're running, but the inherent problem seems to be that they simply don't remember to logout. Since each user has their own SHELL type, i.e. bash, ksh, csh, tcsh, etc., we'll have to create a . file in each of their home directories that contain the timeout for anything more than 7 days. The question is, would this be the way you all handle this or is there a more efficient approach? We can't set this in /etc/profile.d for various reasons, so this is the only way I know to resolve it, even though it will increase administrative overhead until the job is done. Was thinking I might could script it with a "if $USER $SHELL == /bin/tcsh then do timeout".
r/UnixProTips • u/myloverispizza • Dec 18 '17
Any suggestions on how to utilize ITEOC for text alerts?
r/UnixProTips • u/[deleted] • Apr 02 '17
Spotify text formatting help
Has anyone come across a fix for changing the text size in Spotify? On high DPI screens the text is barely readable
r/UnixProTips • u/pspspsps420 • May 19 '23
want a place to learn and share? see what ~vern is about
what is that?
~vern is an interactive community to learn about unix, the shell, internet protocols and much more. while it hosts a lot of services like privacy frontends or git hosting, it has a cozy community that always is there to help! if there's something you may be trying to do with a server, you could even use the pubnix available! ~vern is the greatest place to learn, communicate and discover linux! wanna see more?
r/UnixProTips • u/SiliconRaven • Apr 15 '19
Is there a good way to add lyrics to music library?
I have huge library of music, but the music player I use, does not download synced lyrics it only downloads static lyrics. The developer added an option, upon request, to use a local .lrc file as the lyrics source. I cannot find any good website to download the synced lyrics and my music library is very big. I cannot go adding .lrc files for individual songs. Is there an easier way of doing this? may be a tool (CLI or otherwise) that can crawl through my music library and add .lrc files?
r/UnixProTips • u/bunnieollie • Aug 11 '15
Using for at the command line to ping multiple adresses.
for x in 1 2 3 4 5 6 7 8 9 10; do ping 192.168.1."$x"; done
r/UnixProTips • u/siliconSwordz • Jun 03 '15
read markdown files like man pages
add this in your shell aliases:
# read markdown files like manpages
mdman() {
grep -v "\-\-\-\-\-" "$*" | pandoc -s -f markdown -t man | groff -T utf8 -man | less
}then use it like:
mdman ~/file.mdr/UnixProTips • u/cerebralbleach • Apr 30 '18
If you have pulseaudio installed but need to run a TTY session, you can still run start-pulseaudio-x11 for audio capabilities.
Tried this one day when I logged into a TTY but wanted to fire up cmus in a tmux session. Sure enough, it works. (That said, I didn't realize it was a simple shell script at the time. It's kind enough not to bail out even if it can't find a $DISPLAY.)
Nothing too special, but for those who didn't already know, it might make it just a little easier to entertain yourself during those otherwise tedious troubleshooting sessions.