The (in)famous "FizzBuzz" programming challenge, answered in a single line of Bash code. The "|column" part at the end merely formats the output a bit, so if "column" is not installed on your machine you can simply omit that part. Without "|column", the solution only uses 75 characters. The version below is expanded to multiple lines, with comments added. for i in {1..100} # Use i to loop from "1" to "100", inclusive. do ((i % 3)) && # If i is not divisible by 3... x= || # ...blank out x (yes, "x= " does that). Otherwise,... x=Fizz # ...set x to the string "Fizz". ((i % 5)) || # If i is not divisible by 5, skip (there's no "&&")... x+=Buzz # ...Otherwise, append (not set) the string "Buzz" to x. echo ${x:-$i} # Print x unless it is blanked out. Otherwise, print i. done | column # Wrap output into columns (not part of the test). Show Sample Output
logstalgia must be installed
usb must be bootable with rufus or other
List all your public IPs in an EC2/AWS region, and run an nmap scan against them (ignoring ping response). Requires: aws cli, jq for shell JSON processing Show Sample Output
It's change the group id of all the files on your system that have the OLDGID group as the owner group by the new NEWGID. But first do this:
Document which files will be changed, use:
find / -gid OLDGID ! -type l > resplado-gid.txt
Be sure to disconnect users from the old group.
Stop demons or services associated with the group.
Be sure the new group exist and take note of GID
This is a regular find with the -wholename parameter to let it know what name pattern he need to look and then the -mmin -15 to know the last 15 minutes. Show Sample Output
To recombine split files: cat file.gz.part* > file.gz Show Sample Output
I needed to find a command to delete huge numbers of files without intensive cpu load, that command does the job :) The purpose of "+" at then end of the line, tells rm to delete multiple files at once
Disable password expiration and clear password history for VMware vcenter appliance
Won't work with password login. You must add your RSA key to the server's authorizedkeys file, or change the ssh command adding the -i option for a custom RSA key:
socat "UNIX-LISTEN:/tmp/mysqld.temp.sock,reuseaddr,fork" EXEC:"ssh username@remoteserver.com -i /home/user/rsa-keys/id_rsa socat STDIO UNIX-CONNECT\:/var/run/mysqld/mysqld.sock"
---
/tmp/mysqld.temp.sock will be created locally by socat, don't create it yourself. The folder it lives must be writable. Connect your MySQL client to this socket, with database and username set properly.
---
In case you need to forward a remote socket to a LOCAL PORT instead, check http://www.commandlinefu.com/commands/view/9436/socat-tcp-listen5500-execssh-userremotehost-socat-stdio-unix-connectvarrunmysqldmysqld.sock
pts/33 is variable you can do before you send message to on which pts the user is following ssh youraccount@192.168.1.168 who
For some reason some people do not place files into folders before archiving. This fixes the mess by creating new directories per zip file in directory to unzip to. Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: