Commands by x3mboy (8)

  • Simple commant to tar a path


    -2
    tar -cvzf file.tar.gz path
    x3mboy · 2022-09-17 16:40:09 850
  • Sort disk usage from directories in the current directory Show Sample Output


    2
    du --max-depth=1 -h . | sort -h
    x3mboy · 2022-08-23 14:58:57 480
  • Since systemd-resolved was implemented, add a DNS server have become weirder and harder than before. With this command, you can add a DNS server on-the-fly tied to an specific interface


    5
    sudo systemd-resolve --interface <NombreInterfaz> --set-dns <IPDNS> --set-domain mydomain.com
    x3mboy · 2021-09-21 14:43:48 231
  • It displays the top 10 processes sorted by memory usage Show Sample Output


    3
    ps aux | sort -rk 4,4 | head -n 10
    x3mboy · 2019-09-26 16:37:33 92
  • This command sent the Python version to a file. This is intended to be used in scripts. For some reason, simple redirections didn't work with "python -V" Show Sample Output


    0
    echo "$(python -V 2>&1)" > file
    x3mboy · 2018-11-06 20:52:49 448
  • Short list about top 10 processes, sorted by CPU usage Show Sample Output


    3
    ps aux | sort -rk 3,3 | head -n 10
    x3mboy · 2018-10-29 20:00:36 578
  • This will use tput to place the command (date %T in this case) in the upper right corner of the terminal


    0
    while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-11));echo -e "\e[31m`date +%T`\e[39m";tput rc;done &
    x3mboy · 2017-11-16 18:07:39 19
  • 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


    0
    find /var/log -wholename "*.log" -mmin -15
    x3mboy · 2017-08-03 15:47:43 15

What's this?

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.

Share Your Commands


Check These Out

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

show ls colors with demo
This can show all ls colors, with a demo.

Determine if photos have been rotated to portrait orientation instead of normal landscape orientation
Most people take photos in landscape orientation (wider than it is tall). Sometimes though you turn the camera sideways to capture a narrow/tall subject. Assuming you then manually rotate those picture files 90 degrees for proper viewing on screen or photo frame, you now have a mix of orientations in your photos directory. This command will print out the names of all the photos in the current directory whose vertical resolution is larger than its horizontal resolution (i.e. portrait orientation). You can then take that list of files and deal with them however you need to, like re-rotating back to landscape for consistent printing with all the others. This command requires the "identify" command from the ImageMagick command-line image manipulation suite. Sample output from identify: $ identify PICT2821.JPG PICT2821.JPG JPEG 1536x2048 1536x2048+0+0 8-bit DirectClass 688KB 0.016u 0:00.006

Convert a mp3 file to m4a
I use this to convert mp3 files to m4a files that can be used as ringtones on the iPhone. I've documented the process here: http://www.control-d.com/?p=60

True random passwords using your microphone noise as seed
Generate a truly random password using noise from your microphone to seed the RNG. This will spit out 12 password with 12 characters each, but you can save this into a bash script and replace 'pwgen -ys 12 12' with 'pwgen $@' so you can pass any paramters to pwgen as you would normally do.

Force the script to be started as root
Place this code at the beginning of your script to ensure that it can only be executed by the root.

pass the output of some command to a new email in the default email client
This depends on 'stripansi' and 'urlencode' commands, which exist on my system as these aliases: $ alias stripansi='perl -ple "s/\033\[(?:\d*(?:;\d+)*)*m//g;"' $ alias urlencode='perl -MURI::Escape -ne "\$/=\"\"; print uri_escape \$_"' The `open` command handles URLs on a Mac. Substitute the equivalent for your system (perhaps gnome-open). I don't use system `mail`, so I have this aliased as `mail` and use it this way: $ git show head | mail

Convert all .wav to .mp3
Audio convert is a script that uses zenity and lame to transcode virtually any format to any other format provided you have the libraries installed to do so.

Copy modification timestamp from one file to another.

Adding specific CustomLog for each Virtual Domain of Apache


Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: