Commands tagged Ubuntu (92)


  • 3
    dpkg -l
    linuxrawkstar · 2011-10-17 16:26:29 3

  • 3
    dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge
    yusufk · 2014-01-29 10:42:40 5
  • Compares two versions with dpkg. It is not always obvious what version dpkg/apt will consider to be more recent. Operators include the following : * These treat an empty version as earlier than any version: lt le eq ne ge gt. * These treat an empty version as later than any version: lt-nl le-nl ge-nl gt-nl. * These are provided only for compatibility with control file syntax: < > >. This command doesn't output anything. It only returns with status 0 or 1, hence the echo "y" || echo "n" to get an output. Show Sample Output


    2
    dpkg --compare-versions 1.0-2ubuntu5 lt 1.1-1~raphink3 && echo y || echo n
    raphink · 2009-02-28 18:01:59 5
  • Lets you set all the java alternatives at once to a matching version. Also has options for just changing the jre or the plugin.


    2
    update-java-alternatives
    stuart · 2009-08-09 02:43:06 6
  • This command will transcode a MythTV recording. The target device is a Google Nexus One mobile phone. My recordings are from a HDHomerun with Over The Air content. Plays back nicely on the N1.


    2
    ffmpeg -i /var/lib/mythtv/pretty/Chuck20100208800PMChuckVersustheMask.mpg -s 800x480 -vcodec mpeg4 -acodec libfaac -ac 2 -ar 16000 -r 13 -ab 32000 -aspect 16:9 Chuck20100208800PMChuckVersustheMask.mp4
    PLA · 2010-02-12 12:11:02 7
  • if you haven't already done so, install lame and flac: sudo apt-get install lame flac Show Sample Output


    2
    flac -cd input.flac |lame -h - output.mp3
    nickleus · 2010-03-05 23:54:21 4
  • Change the APP variable's value to whatever you want to install. Depending on how fast your machine is, you'll want to adjust the value 50 to something else. You might also want to play a different game than Gnometris - just make sure it's a GUI game.


    2
    APP=wine; if [ $(sudo apt-get --print-uris -y install $APP | sed -ne 's/^After this operation, \([0-9]\{1,\}\).*MB.*/\1/p') -gt 50 ]; then gnometris 2>/dev/null & sudo apt-get install $APP; else sudo apt-get install $APP; fi
    rkulla · 2010-04-18 19:32:26 39
  • As of 10.04 LTS, you need to use this command-line to reports bugs to the launchpad.net tracking system (you need a launchpad acct for this to work). This command is preferred over using the website because it collects/sends info about your system to help developers. ubuntu-bug is a symlink to apport-bug which sees if KDE/Gnome is running and calls apport-gtk/apport-kde dialogs, otherwise apport-cli, so you can fill out a bug report. First run 'ubuntu-bug' without args to see a list of known symptoms. If there's no matching symptom, or you know which package is to blame, then run 'ubuntu-bug <package>'. If the process is still running, use 'ubuntu-bug <PID>'


    2
    ubuntu-bug
    rkulla · 2010-05-02 20:24:32 3
  • i have a large video file, 500+ MB, so i cant upload it to flickr, so to reduce the size i split it into 2 files. the command shows the splitting for the first file, from 0-4 minutes. ss is start time and t is duration (how long you want the output file to be). credit goes to philc: http://ubuntuforums.org/showthread.php?t=480343 NOTE: when i made the second half of the video, i got a *lot* of lines like this: frame= 0 fps= 0 q=0.0 size= 0kB time=10000000000.00 bitrate= 0.0kbit just be patient, it is working =) Show Sample Output


    2
    ffmpeg -i 100_0029.MOV -ss 00:00:00 -t 00:04:00 100_0029_1.MOV
    nickleus · 2010-08-08 23:43:28 3
  • this will open a new tab in firefox for every line in a file the sleep is removable but i found that if you have a large list of urls 50+, and no sleep, it will try to open all the urls at once and this will cause them all to load a lot slower, also depending on the ram of your system sleep gives you a chance to close the tabs before they overload your ram, removing & >2/dev/null will yield unpredictable results.


    2
    for line in `cat $file`; do firefox -new-tab "$line" & 2>/dev/null; sleep 1; done
    hamsolo474 · 2011-11-12 13:47:24 3
  • This script will run each time you boot up.The script must be in /etc/init.d directory.


    2
    sudo update-rc.d <scriptname> defaults
    Dhinesh · 2011-11-19 08:55:38 6
  • This handles when you have a single call or channel. Other commands will strip out the result if there is a single channel or call active because the output changes the noun to be singular instead of plural. Show Sample Output


    2
    watch "asterisk -vvvvvrx 'core show channels' | egrep \"(call|channel)\""
    rowshi · 2012-08-29 13:40:45 5
  • Requires: curl xsel access to the internet(http://transfer.sh) This is an alias utilizing the transfer.sh service to make sharing files easier from the command line. I have modified the alias provided by transfer.sh to use xsel to copy the resulting URL to the clipboard. The full modified alias is as follows since commandlinefu only allows 255 characters: transfer() { if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" |xsel --clipboard; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" |xsel --clipboard ; fi; xsel --clipboard; } Show Sample Output


    2
    transfer() { basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g');curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile"|xsel --clipboard;xsel --clipboard ; }
    leftyfb · 2016-03-20 19:38:48 12
  • I put this command on my ~/.bashrc in order to learn something new about installed packages on my Debian/Ubuntu system each time I open a new terminal Show Sample Output


    2
    dpkg-query --status $(dpkg --get-selections | awk '{print NR,$1}' | grep -oP "^$( echo $[ ( ${RANDOM} % $(dpkg --get-selections| wc -l) + 1 ) ] ) \K.*")
    acavagni · 2019-06-01 13:24:07 45
  • Displays only the VGA adapter/chipset being used for the graphics. In this case, it gave me the "M22" and "Mobility Radeon x300" that I needed to research a graphics issue I was having. Show Sample Output


    1
    lspci |grep VGA
    CafeNinja · 2009-04-28 08:34:42 9
  • Use sed to comment out any up/down bindings in zsh


    1
    sudo sed -iorig '/\(up\|down\)/s/^/#/' /etc/zsh/zshrc
    cbrinker · 2010-02-02 23:17:08 27
  • I had problems in Ubuntu while trying to edit /etc/resolv.conf, even with sudo I couldn't make any change. After a 2 minutes search on google I found this command. Hope someone finds it useful. It works like chmod, with + and - to denote which attributes are being added and which are being removed. See other attributes on man pages or on wikipedia http://en.wikipedia.org/wiki/Chattr


    1
    sudo chattr -i <file that cannot be modified>
    leovailati · 2010-03-25 03:14:34 4
  • Only the number of calls nothing else. Show Sample Output


    1
    /usr/sbin/asterisk -rx 'core show channels' | grep -m1 "call" | cut -d' ' -f1
    stackoverflow128 · 2012-02-01 17:55:17 5
  • The command tasksel allows the choice of packages from the command line to get predefined configurations for specific services (usually this option is offered during installation).


    1
    tasksel list-tasks
    0disse0 · 2012-02-03 16:13:17 5
  • Bash snippet to force GNU/Linux keyboard settings, layout and configuration. Usefull when some GNU/Linux distributions such as *Ubuntu's store only limited configation options due to demonstration purposes on LiveUSB or Live persistent devices. Overcomes the English QWERTY to French AZERTY settings failure. Code bash en ligne de commande pour forcer l'adoption du clavier AZERTY sur les cl? USB bootable en Ubuntu.


    1
    sudo dpkg-reconfigure keyboard-configuration
    arsenerichard · 2012-03-27 21:07:45 47
  • locating packages held back, such as with "aptitude hold "


    1
    aptitude search ~ahold
    pykler · 2012-04-29 15:02:32 4
  • Taken from apticron and modified. Show Sample Output


    1
    apt-get --ignore-hold --allow-unauthenticated -s dist-upgrade | grep ^Inst | cut -d ' ' -f2
    phunehehe · 2013-01-07 11:21:58 4
  • Backs up all databases, excluding test, mysql, performance_schema, information_schema. Requires parallel to work, install parallel on Ubuntu by running: sudo aptitude install parallel


    1
    mysql -e 'show databases' -s --skip-column-names | egrep -v "^(test|mysql|performance_schema|information_schema)$" | parallel --gnu "mysqldump --routines {} > {}_daily.sql"
    intel352 · 2013-07-24 15:37:58 11
  • The other commands were good, but they included packages that were installed and then removed. This command only shows packages that are currently installed, sorts smallest to largest, and formats the sizes to be human readable. Show Sample Output


    1
    dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' `aptitude --display-format '%p' search '?installed!?automatic'` | sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n", $2/(1024), $1}'
    EvilDennisR · 2013-07-26 23:18:20 13
  • In this case, linux- is the prefix; simply running apt-cache pkgnames would list every package APT knows about. The default APT config assumes -g, --generate; to use the cache as/is, you could similarly run: apt-cache --no-generate pkgnames [prefix] Adding --all-names, like so: apt-cache --no-generate --all-names pkgnames [prefix] would print all the packages APT knows about, using the cache as/is, including virtual packages and missing dependencies. This command was shamelessly stolen from the apt-cache(8) man-page. Show Sample Output


    1
    apt-cache pkgnames linux-
    benjabean1 · 2014-12-14 06:48:57 8
  •  < 1 2 3 4 > 

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

Serial console to a Vmware VM
Create a serial console with "socket (named pipe)" of "/tmp/socket", "from:server, to:virtual machine" in vmware player, etc.. gui. Run the above command after you have booted the guest OS (which should also be configured for serial console).

Play musical notes from octave of middle C
Are there any creative pieces of music that can be created using beep and the shell? I'd love to hear it!

Create a bash script from last commands
In order to write bash-scripts, I often do the task manually to see how it works. I type ### at the start of my session. The function fetches the commands from the last occurrence of '###', excluding the function call. You could prefix this with a here-document to have a proper script-header. Delete some lines, add a few variables and a loop, and you're ready to go. This function could probably be much shorter...

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Quick HTML image gallery from folder contents
Setting: You have a lot of jpg files in a directory. Maybe your public_html folder which is readable on the net because of Apache's mod_userdir. All those files from the current folder will be dropped into a file called gallery.html as image tags that can be viewed within a web browser locally or or over the Internet. Original: $find . -iname "*.jpg" -exec echo "" >> gallery.html \;

Test file system type before further commands execution
Exclude 400 client hosts with NFS auto-mounted home directories. Easily modified for inclusion in your scripts.

Convert (almost) any video file into webm format for online html5 streaming

This will allow you to browse web sites using "-dump" with elinks while you still are logged in
README: This require you to login on facebook with elinks without using '-dump' first time and when you have logged in you will then be able to dump all data from facebook without any advanced combos, dump is all you need for see all your friends newsfeed or whatever you wish to view in cli/terminal. Facebook is just an example, same requirements for all websites that have a login form.

backup local MySQL database into a folder and removes older then 5 days backups

Disassemble all ACPI tables on your system
The fact that Linux exposes the ACPI tables to the user via sysfs makes them a gold mine of valuable hardware information for low-level developers. Looping through each of them and disassembling them all makes them even more valuable.


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: