This is bad juju. 'find . -type d -exec chmod g+x {} \;' If you happen to have a malicious directory named (without double quotes): ".;sudo rm -rf /" You'd be stuffed. It's better practice to use the '-print0' flag of find(1) and pipe the result into xargs(1) with the '-0' flag set. For safety, it's best to also use '-r #' for expected number of arguments, '-n' to stop xargs from running without arguments, and "-J %"…
This is simply not true: $ mkdir '; echo woops' $ find . -type d -exec echo {} ';' . ./; echo woops As you can see 'woops' is never echoed. EDIT: The reason being the shell is never involved in this process, and the shell is what is responsible for splitting commands on semicolons/newlines.
Unix tricks
81–90 of 232 posts
Re: Unix tricks
#82Earlier quoted context omitted.
Not trying to contradict you, just some explanations 1. I prefer 'psgrep' because it covers 99% of my use cases for pgrep (ps axuf | grep $NAME) 2. htop is very nice, come on! Would not let it running on the background for hours, but it's nicer than top 3. Note taken, thanks! 4. Is ssh-agent really safer than using passwordless keys? Just asking, I'm curious
1. `man pgrep` is your friend (you save two greps, and TBH the `grep -v grep` should be a hint that there's a better way) 2. In my experience on Debian (granted this was in 2010), there is a noticeable performance difference between `htop` and `top`. 4. ssh-agent stores the password in memory and is erased on reboot. OTOH If you use a passwordless key file, anyone can use it if they have the key.
Re: Unix tricks
#83Instead of find . -type d -exec chmod g+x {} \;' you can usually use chmod -R g+X . which gives additionally the group execute permission to files which have already user/everyone execute permission.
Re: Unix tricks
#84Earlier quoted context omitted.
Not trying to contradict you, just some explanations 1. I prefer 'psgrep' because it covers 99% of my use cases for pgrep (ps axuf | grep $NAME) 2. htop is very nice, come on! Would not let it running on the background for hours, but it's nicer than top 3. Note taken, thanks! 4. Is ssh-agent really safer than using passwordless keys? Just asking, I'm curious
1. `man pgrep` is your friend (you save two greps, and TBH the `grep -v grep` should be a hint that there's a better way) 2. In my experience on Debian (granted this was in 2010), there is a noticeable performance difference between `htop` and `top`. 4. ssh-agent stores the password in memory and is erased on reboot. OTOH If you use a passwordless key file, anyone can use it if they have the key.
Re: Unix tricks
#85Re: Unix tricks
#86tar czf - . | ssh destination "tar xz" To pipe all the contents of your current directory (including dotfiles) to the destination machine. Greetings from LSI-UPC!
I would change this to: tar czf - . | ssh destination "cd /remote/dir; tar xz"
Re: Unix tricks
#87Earlier quoted context omitted.
Not trying to contradict you, just some explanations 1. I prefer 'psgrep' because it covers 99% of my use cases for pgrep (ps axuf | grep $NAME) 2. htop is very nice, come on! Would not let it running on the background for hours, but it's nicer than top 3. Note taken, thanks! 4. Is ssh-agent really safer than using passwordless keys? Just asking, I'm curious
re: 4: not only is an ssh agent by far safer, but most agents now allow you to set a timeout on a key, so it's not indefinitely saved in memory. A passwordless key gives anyone with acces to that file, access to the login associated with it. If that file is inadvertently exposed (oops, checked it into github...), any machine you have a login on must be considered compromised.
For example if you login remotely to a machine, and want to access a git repository on another:
$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/id_
$ ssh -A
you@firstserver$ git clone git+ssh:///path/to/repositoryRe: Unix tricks
#88find . -name "file-wildcard" -exec "string" {} ";" -print is something I use a lot - plus xargs sometimes
Re: Unix tricks
#89Re: Unix tricks
#90I freaked out when I found out about the "screen" command several years back. "screen" starts a virtual screen that you can detach from with "ctrl-a d" and you can log out, login from a different machine/session and reattach with "screen -r". it has history so you can run long running commands and reattach 3 days later to continue from where you left off as if you had been logged in the whole time.
"screen -X -S minecraftserver -p 0 -X stuff "say test $(printf '\r')"