Commands tagged kernel (37)

  • Needed a quick way to see if my server distro that I setup years ago was running 32bit or not, since with time I had forgotten. Note: does not check _hardware_ e.g. /proc/cpuinfo but rather the kernel installed Show Sample Output


    21
    getconf LONG_BIT
    varghjarta · 2012-12-12 23:51:51 12

  • 16
    arch
    anapsix · 2013-01-02 17:52:14 9
  • This should do the same thing and is about 70 chars shorter. Show Sample Output


    8
    aptitude remove $(dpkg -l|egrep '^ii linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`)
    dbbolton · 2010-06-10 21:23:00 10
  • Note the double space: "...^ii␣␣linux-image-2..." Like 5813, but fixes two bugs: [1]This leaves the meta-packages 'linux-headers-generic' and 'linux-image-generic' alone so that automatic upgrades work correctly in the future. [2]Kernels newer than the currently running one are left alone (this can happen if you didn't reboot after installing a new kernel). I'm bummed that this took 228 characters. I'd like to see a simpler version. Show Sample Output


    7
    aptitude remove $(dpkg -l|awk '/^ii linux-image-2/{print $2}'|sed 's/linux-image-//'|awk -v v=`uname -r` 'v>$0'|sed 's/-generic//'|awk '{printf("linux-headers-%s\nlinux-headers-%s-generic\nlinux-image-%s-generic\n",$0,$0,$0)}')
    __ · 2010-12-11 11:38:15 7
  • Use `sysctl -p` without argument will only load /etc/sysctl.conf, but user configs always put in /etc/sysctl.d/*.conf, `sysctl --system` will load all the config files


    7
    sysctl --system
    tankywoo · 2015-01-29 07:56:36 14
  • depends on "jq" This is more reliable in my opinion. Show Sample Output


    5
    curl -s https://www.kernel.org/releases.json | jq '.latest_stable.version' -r
    ernierasta · 2019-03-06 08:48:04 42
  • This will remove all installed kernels on your debian based install, except the one you're currently using. From: http://tuxtweaks.com/2009/12/remove-old-kernels-in-ubuntu/comment-page-1/#comment-1590


    4
    dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
    mitzip · 2010-06-10 20:33:32 5
  • Lists all installed kernels minus the current one. This is useful to uninstall older kernels that take too much space on /boot partition. Show Sample Output


    4
    dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'
    bugmenot · 2021-10-30 22:32:29 311
  • Remove old kernels (*-generic and *-generic-pae) via apt-get on debian/ubuntu based systems. Tested on ubuntu 10.04 - 12.04.


    3
    sudo apt-get remove $(dpkg -l|awk '/^ii linux-image-/{print $2}'|sed 's/linux-image-//'|awk -v v=`uname -r` 'v>$0'|sed 's/-generic*//'|awk '{printf("linux-headers-%s\nlinux-headers-%s-generic*\nlinux-image-%s-generic*\n",$0,$0,$0)}')
    mtron · 2012-08-15 10:02:12 6

  • 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
  • Lockstat will sample the kernel 977 times per second, and print out the functions that it sees executing on the CPU during the sample. The -s 10 switch tells lockstsat to not only print that function, but also show the call stack (up to 10 deep). Show Sample Output


    2
    lockstat -I -i 977 -s 30 -h sleep 1 > /tmp/profile.out
    garylittle · 2009-03-13 13:17:53 4
  • A little aptitude magic. Note: this will remove images AND headers. If you just want to remove images: aptitude remove ?and(~i~nlinux-im ?not(~n`uname -r`)) I used this in zsh without any problems. I'm not sure how other shells will interpret some of the special characters used in the aptitude search terms. Use -s to simulate.


    2
    aptitude remove ?and(~i~nlinux-(im|he) ?not(~n`uname -r`))
    dbbolton · 2010-06-11 22:57:09 6
  • These are way better than fortune(6). Show Sample Output


    2
    grep -2riP '\b(fuck|shit|bitch|tits|ass\b)' /usr/src/linux/
    h3xx · 2011-07-27 23:11:02 7

  • 2
    sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")
    funkjedi · 2015-03-15 15:57:19 9
  • TIMTOWTDI


    1
    perl -e 'chomp($k=`uname -r`); for (</boot/vm*>) {s/^.*vmlinuz-($k)?//; $l.="linux-image-$_ ";} system "aptitude remove $l";'
    dbbolton · 2010-06-10 22:16:47 3
  • Use modprobe to list all the dependencies of a certain kernel module. Handy when debugging system issues. Show Sample Output


    1
    modprobe --show-depends module_name
    miguelcnf · 2012-08-17 16:54:52 4
  • This is likely only valid on Solaris based systems. Unfortunately a lot of the more universal techniques for determining if a system is 32bit or 64bit on x86 solaris fail to give much more information than "i86pc" Show Sample Output


    1
    isainfo -v
    halcyonblue · 2013-01-04 03:07:28 5
  • Reload all defined kernel variables from /etc/sysctl.conf(if no parameter after -p is given) without the old myth "Ah, you'll need to reboot to apply those variables"... Show Sample Output


    1
    /sbin/sysctl -p
    Risthel · 2013-02-14 12:48:26 3
  • Returns the version of the kernel module specified as "MODULENAME", when available. Show Sample Output


    1
    lsmod | grep -io MODULENAME| xargs modinfo | grep -iw version
    adriano · 2013-03-18 07:52:14 14
  • Linux offers an interesting option to restrict the use of dmesg. It is available via /proc/sys/kernel/dmesg_restrict. You can check the status with: cat /proc/sys/kernel/dmesg_restrict Alternatively you can use sysctl: sudo sysctl -w kernel.dmesg_restrict=1 To make your change persistent across reboot, edit a fille in /etc/sysctl.d/.


    1
    sudo sh -c 'echo 1 > /proc/sys/kernel/dmesg_restrict'
    Blacksimon · 2015-03-13 20:54:45 11
  • If, for example, you want to remove all kernels and headers but the last three versions, you can't use one of that magic all-in-one "remove old stuff" commands. With this simple but elegant command you can remove a range of versions, or a list of versions with e.g. {14,16,20}. Show Sample Output


    1
    apt purge linux*{14..18}*
    ppq · 2016-04-20 07:44:55 11
  • The platform-agnostic version of https://www.commandlinefu.com/commands/view/25276/compute-newest-kernel-version-from-makefile-on-torvalds-git-repository because macOS doesn't have wget installed


    1
    curl -s -o - https://raw.githubusercontent.com/torvalds/linux/master/Makefile | head -n5 | grep -E '\ \=\ [0-9]{1,}' | cut -d' ' -f3 | tr '\n' '.' | sed -e "s/\.$//"
    realkstrawn93 · 2023-08-10 22:25:55 227
  • zless /proc/config.gz


    0
    zgrep CONFIG_MAGIC_SYSRQ /proc/config.gz
    h3xx · 2011-07-24 02:06:09 4
  • Then exit from the shell. exit some time need to exit twice exit exit Now the OS will boot with the new parameters.


    0
    echo "root=/dev/sda7" > /proc/param.conf
    totti · 2011-09-27 18:06:53 5
  • since awk was already there one can use it instead of the 2 greps. might not be faster, but fast enough


    0
    apt-get remove $(dpkg -l | awk "/^ii linux-(image|headers)/ && ! /`uname -r`/ {print \$2}")
    _john · 2011-10-09 13:58:47 4
  •  1 2 > 

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

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Rename files in batch

Download an Entire website with wget

Set laptop display brightness
Run as root. Path may vary depending on laptop model and video card (this was tested on an Acer laptop with ATI HD3200 video). $ cat /proc/acpi/video/VGA/LCD/brightness to discover the possible values for your display.

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

a short counter
Maybe you know shorter ?

Log colorizer for OSX (ccze alternative)
Download colorizer by @raszi @ http://github.com/raszi/colorize

add all files not under version control to repository
This should handle whitespaces well and will not get confused if your filenames have "?" in them

Sort netflow packet capture
Sort netflow packet capture by unique connections excluding source port.

back ssh from firewalled hosts
host B (you) redirects a modem port (62220) to his local ssh. host A is a remote machine (the ones that issues the ssh cmd). once connected port 5497 is in listening mode on host B. host B just do a ssh 127.0.0.1 -p 5497 -l user and reaches the remote host'ssh. This can be used also for vnc and so on.


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: