Main Menu

search

You are here

Linux: system level commands

[last updated: 2024-03-18]
Linux home page
Linux commands
-----

ps, df, raspi-config, reboot, shutdown, dpkg, cat /proc/version and other variations, uname, python --version

  • hardware info:
    • $ uname -m ... shows whether 64-bit or 32-bit system
    • lscpu ... shows processor and related info
  • memory (MemTot):
    $ cat /proc/meminfo
  • memory (free):
    $ df or df -h
  • processes running:
    $ ps ... lists all processes running (use sudo to see all of them...)
    $ ps -A ... lists info on them
    or - $ ps axg
  • $ sudo raspi-config ... opens original bootup menu for setting various preferences (such as enabling i2c)
  • update & upgrade:
    • These commands update to most current version of software packages. They do Not change your installed core version of Raspbian.
      However there is lots of chat in the forums about the proper/best form/syntax to use. Some of it depends on age/version of your software.
      In any case, here's what I use now:
      • $ sudo apt update
      • $ sudo apt upgrade
    • Some of the forums suggest that upgrade does not remove things that are no longer needed because dependencies have changed.
      If you want to do that, you can follow upgrade with $ sudo apt autoremove
      Or, you can instead use $ sudo apt dist-upgrade, which will correct changed dependencies for you,
      However it's recommended to use dist-upgrade with caution because it can change things you may not want changed...
    • There is also forum chat about the difference between apt and apt-get.
      My best guess is that apt is currently considered to be the best.
  • =================================================
      -----------------------------------------------------------------

      -----------------------------------------------------------------

    • $ cat /proc/sys/vm/swappiness
      Default is 60; lower may speed up operation by reducing the amount of memory swaps that happen.
    • Available Disk Space:
      $ df
      "disk free" shows usage and availability of all partitions
    • List Installed Disks:
      $ lsblk
    • dpkg [options] ...
      $ dpkg --get-selections (shows modules/packages that are installed)
      $ dpkg -l (appears to do the same thing)
      $ dpkg -s [pkg name] (shows whether a particular package is installed)
      $ dpkg -c (shows detailed contents of a package)
      $ dpkg -L (shows location of installed package)
      $ dpkg -p [pkg name] (shows details of the package)
    • Find version of Linux Kernel you have:
      $ uname -r
      $ hostnamectl | grep Kernel
      $ cat /proc/version

  • Linux & Python info:
    • $ cat /etc/os-release ... returns Linux version
      $ lsb_release -a ... returns the same but shorter (less detail)
      $ hostnamectl ... returns Linux (OS) info, as well as hardware and kernel info
      $ uname -r ... returns Linux kernel

    • $ ls /usr/bin/python* ... what versions of python are loaded?
    • $ python ... what version of python is default?
      This actually opens a python command line interpreter,
      in which you can enter python commands.
      But the opening header lists the version of python that is being executed.
      To exit the program, type <ctrl>d
    • $ python --version ... same
      shows I'm using 3.5.3 (after having done below procedure for updating alternatives list)
    • If you want to change to a different default version of python:
      • first see what's in the "symbol list":
        $ update-alternatives --list python
      • if error, then - no alternatives.
        However it is possible for versions to be installed but still not added to the symbol list,
        so update the list:
        • $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
          $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.2 2
          The '1' and '2' at the end of the command is the priority.
          The default will be the one with the highest priority.
      • confirm changes with:
        $ sudo update-alternatives -- list python
        $ python --version
      • now you can change default with:
        $ update-alternatives --config python
        and enter the selection number desired from the table

    • What version of Linux am I running?
      $ cat /etc/os-release
      says I'm currently running Debian Raspbian Linux 9 stretch
      previous versions were: 7 wheezy and 8 jessie

eof