Tuesday, November 22, 2016

Raspbian Command Line Basics 102

This is continuation from Raspbian Command Line Basics 101


Here are 18 commands on configurations of Raspbian Jessie or Release 8.0 on a Raspberry Pi 2. This might work for other versions of Raspbian, as they are common Linux commands in most cases.

At the Raspbian terminal, users can access a whole load of information. These can be useful for troubleshooting graphics, program conflicts and networking issues.

GENERAL

Display your device name and operating system information
$ uname -a

Change directory
$ cd directoryname

List files n a directory
$ ls
or
$ ls directoryname

Restart background services
$ sudo systemctl daemon-reload

Display disk usage or free space
$ free
$ free -h

Display disk usage by partitions
$ df -h

Display contents of a file
$ cat filename
e.g. to display CPU type
$ cat /proc/cpuinfo

Display the system date and time
$ date

Edit a file with Vim or Nano
$ vi filename
or
$ nano filename

Schedule shutdown at specific time
$ shutdown -h 21:00
or reboot
$ shutdown -r now

Configure Raspbian
$ sudo raspi-config

PACKAGE MANAGEMENT

List installed packages
$ dpkg-query -l

To clear up disk space before updating
$ sudo apt-get clean

Update Raspbian system packages
$ sudo apt-get update

Upgrade installed packages
$ sudo apt-get dist-upgrade

Install a package
$ sudo apt-get install mypackagename
or
$ sudo apt-get install mypackagename -y

Remove an installed package
$ sudo apt-get remove mypackagename
or complete removal with its configuration files
$ sudo apt-get purge mypackagename

Search for a package online
$ apt-cache search mypackagename

Display information of a package
$ apt-cache show mypackagename


NETWORKING

Default networking file is configured at
/etc/dhcpcd.conf

And the dhcpcd controls the networking interfaces

Display existing network interface settings
$ ifconfig


Display network routing table
$ route 
or display all numericals
$ route -n

Changes to the static ip in configuration file requires restart of the dhcpcd
$ sudo dhcpcd -k
$ sudo dhcpcd

Display status of running network interfaces
$ sudo service networking status

Restart network interfaces. Required after changes to network configuration.
$ sudo service networking restart

When there is network but web browser display "Unable to resolve name". Edit the domain name server at /etc/resolv.conf

nameserver x.x.x.x


No comments:

Blog Archive