Skip to main content

Useful Raspbian Commands

more command

You can use more command instead cat command to view the contents of a file. For example:

more /etc/network/interfaces
You can now see catalog of your network interfaces file on the terminal window.

Get the calender

The cal command displays a text based calender on your terminal. But your Raspberry Pi has no real time clock you should connect to Internet for accessing correct date.

What is my Disk Usage?

One advantage that Windows and Macintosh systems have over Unix is that they make it easy to find out how much disk space you’re using and how much remains available. On Windows, each partition of your hard disk says itself about disk space used.

Like a close-mouthed police informant, Unix never volunteers any information, so you need to learn two new commands. The du (disk usage) command is used to find out how
much disk space is used; the df (disk free) command is used to find out how much space is available.

du


du -h /opt or
du -hs /opt/* or
Shows your disk usage. Here our disk SD Card. The du command find out how much space a directory tree uses. 
Options: (-h) human readable form, (-s) summary, (-c) total. 
du -hc *.mp4
While the command shown above finds the total size of the mp4 format files in the current directory.

df

df -h
Display available system disk space in (-h) human-readable form.

echo

The echo command simply echoes a string, output of a command, or a value to the standard output. Here is an example:
echo 'how are you?'
This command gives output how are you. That is it is an echo of whatever we are typed in single quotes.

We can use I/O redirection for store output of this commands as text files. This is the only advantage of this echo command.

uptime

This command uptime returns how long the system has been running.

Which Linux Distribution you are using?

more /etc/issue returns the Linux distribution you are using. Use cat instead more and observe the result.

Which is your currently using shell?

ps -p $$ returns the shell you are currently using (e.g., bash).

How can I find out executing processes and programs?

The top command lists all of the processes and programs executing. Press Ctrl+C to close the view.

Shutting down and Reboot

Physically disconnecting the power without allowing the Linux kernel 
to unmount the micro-SD card can cause corruption of your file system.
But I disconneced it power without shutting down the Raspberry Pi. But it didn't corrupted my SD card. It may be due to I am lucky. But I only prefer you to shutdown using command or using shutdown option available on menu.

Improper shutdown can potentially corrupt the ext4 file system and/or lead to increased boot times due to file system checks. Here are some important points on shutting down, rebooting, and starting the RPi:
  • Typing sudo shutdown -h now shuts down the board correctly. You can delay this by five minutes by typing sudo shutdown -h +5. The above commands are lengthy. From my personal experience sudo halt also does the same job.
  • Typing sudo reboot will reset and reboot the board correctly.
If your project design is enclosed and you need an external soft power down, it is possible to wire an external button to an RPi GPIO input and write a shell script that runs on startup to poll the GPIO for an input. If that input occurs, /sbin/shutdown -h now can be called directly.

Is Raspberry Pi Comes with Hardware Reset?

Here is I am not saying about Raspbian command. That is why I am changed the font color. Some times it is necessary to hardware reset your Raspberry Pi since, in some rare cases software reset may not work. For these conditions what can you do?
You may see that Run header on your Raspberry Pi. The RPi does not have a power or a reset button, which means that if a system lock-up occurs you must unplug and replug the micro-USB power supply. This task can be awkward and can lead to physical damage of the RPi. (On older models, a common issue is that a large 220 μF capacitor is often used for physical leverage when unplugging the USB power input and it tends to fall off !)

The run headers are shown below:
The Raspberry Pi Run header: Courtesy Adafruit
You can short circuit to reset your Raspberry Pi. For future use you can also connect your PC power/reset switch after soldering berg pins to this header.

PC Power reset button
I know the name of file. But don't what is the path of file. How can I find out where is my file?

The find command helps you to find out your file in this condition. Consider your name of file is GPIO.txt. You can find out this file using following command:
find .  -name "GPIO.txt"

Here (.) is used to begin the search from current directory. According relative path (./ ) or simply (.) represents your current directory. If you want to begin your search from one directory up from your working directory use(..) instead (.). If you want to start your search from root directory put (/) instead (.). If you begin search from root directory you can see that terminal verbosing that permission denied. So you want to use sudo to begin search from root as shown:
sudo find / -name "GPIO.txt"

If you want to get the path of all text files starting from root, you can use wildcard entry as follows:
sudo find / -name "*.txt"

If you only interested to search from your current working directory use this command instead above command:
find . -name "*.txt"

Comments

Popular posts from this blog

8051 Simple Programs

Sum of 8-bit Numbers Stored in Memory Here  we will discuss about 8051 programs but we can't discuss about all of the 8051 instructions. For programming 8051 we should know about assembler directives as well as instruction set. Click  here to download Atmel c51 user guide that will discuss about 8051(c51 family microcontroller) instruction set, assembler directives, c51 cross assembler from Atmel.  Program ORG 00H MOV R0,#50H   ; get memory location in memory pointer R0 MOV R1,#51H   ; get memory location on memory pointer register R1 MOV A,@R0       ; get content of memory location 50H to accumulator ADD A,@R1        ; add content of A with content of memory location 51H and store result in A MOV R0,#52H    ; get 52H to memory pointer R0 MOV@R0,A         ; copy content of A to memory location 52H END Add 16-bit Numbers ...

Introduction to 8051 embedded C

For 8051 we need to include the file reg51.h. This file contains the all the definitions of 8051 registers. With this information C compiler produces hex file that can be downloaded into the ROM of the microcontroller. It is important to note that the size of the hex file produced by the assembly language is much larger than the hex file produced by C compiler. Apart from this fact, there is many reasons for writing programs in C instead of assembly: ●It is much easier and less time consuming to write programs in C assembly. ●C is more flexible; it is easier to modify and update. ●Programming in C allows to use code available in function libraries. ●Program written inC for one microcontroller is portable to other microcontrollers with little or no modifications. Data Types in 8051 Embedded C The table shown below lists the data types that are available in typical C51 compiler. The gives information about the size of the data variable and it's value range. Data type ...

Frequency of Oscillation of RC Phase Shift Oscillator

Derivation of Frequency of Oscillation We have to find out the transfer function of RC feedback network. Feedback Circuit of RC Phase Shift Oscillator Applying KVL to various loops on the figure, we get, $$I_1 \left(R+\frac{1}{j \omega C }\right) -I_2R=V_i \text{ ....(1)}$$ $$-I_1R+I_2\left (2R+\frac {1}{j\omega C}\right)-I_3R=0\text{ ... (2)}$$ $$0-I_2R+I_3\left(2R+ \frac{1}{j\omega C}\right)=0\text{ ...(3)}$$ Replacing \(j\omega\) with \(s\) and writing equations in the matrix form, $$\begin{bmatrix}R+\frac{1}{sC} & -R & 0 \\-R & 2R+\frac{1}{sC} & -R \\0 & -R & 2R+\frac{1}{2sC} \end{bmatrix}\begin{bmatrix}I_1\\I_2\\I_3\end{bmatrix}=\begin{bmatrix}V_i\\0\\0\end{bmatrix}$$ Using Cramer's rule to find out \(I_3\), $$\text{Let, }D=\begin{bmatrix}R+\frac{1}{sC} & -R & 0 \\-R & 2R+\frac{1}{sC} & -R \\0 & -R & 2R+\frac{1}{2sC} \end{bmatrix}$$ \(|D|=\begin{vmatrix}R+\frac{1}{sC} & -R & 0 \\-R & 2R+\frac{1}{...