Skip to main content

More Useful Raspbian Commands

Make and Extract tar files

The tar command is an archiving utility that enables you to combine files and directories into a single file (like an uncompressed zip file). This file can then be compressed to save space. To archive and compress a directory of files, such as /var, use the following:

pi@raspberry ~ $ tar cvfz var_backup.tar.gz /var

In the following commands (c) means new archive, (v) means verbosely list files, (z) means compress with gzip, (r) means append files to the end if tar archive (j) option tells tar to read or write archives using the bzip2 compressor, and (f) means archive name follows. You might also see .tar.gz represented as .tgz.

• tar cvfz name.tar.gz /var
This command compress with gzip form.
• tar cvfj name.tar.bz2 /var
Compress with bzip2 compression (typically a longer delay, but smaller, file). Enter all commands in this table on a single line.
tar cvfJ name.tar.xz /var
Compress with xz file format (used in .deb package files)
• tar xvf name.tar.*
Decompress compressed fi le (x indicates extract). It will auto-detect the compression type (e.g., gzip, bz2).
• tar xvf name.tar.* /dir/file
Extract a single fi le from an archive. Works for a single directory too.
• tar rvf name.tar filename
Add another file to the archive.

tar cfz name-$(date +%m%d%y).tar.gz /dir/filename
Create an archive with the current day’s date; useful for scripts and cron job backups. Note that there must be a space between date and +%m%d%y.

Logging in as Root

As I concern as root is not only simply a directory but also it is the one and only user of your Raspbian OS. By default the directory /home/pi is a user group. It has no root access or neither administrative power. In order to solve this problem we can use sudo su or sudo -i commands to login as root.

The sudo su used for switch one user to another. Since there is only one user sudo su takes you to root. If there were a user group with name arun under /home sudo su arun switches you to arun after giving correct password for login as arun. We can also create user groups that has all administrative privileges like root. I will explain it later.

The sudo -i command login you to root and it will give you more I/O control and give chance to login to any interactive shell. Since sudo -i gives more I/O control I will prefer you to use sudo -i on your Raspberry Pi.

How can I check my memory card has bad blocks or not?

badblocks /dev/mmcblkX

Check for bad blocks on the SD card. SD cards have wear leveling 
controller circuitry. If you get errors, get a new card; don’t record them using fsck. Run this with root permissions and be aware that it takes some time to run. The X in this command is usually a number. To know this number use follow command:
ls /dev/

This will list all of the directories and file in the dev directory. From this you can find out some files like mmcblk0, mmcblk1, mmcblkX 2 etc.. It is not easy to find out which file is exactly contains the information about badblock of memory card. So use alternative values for X until this command gets executed. Don't blindly use values for X the output of ls /dev/ will help you to choose value for X as I mentioned earlier.

Comments

Post a Comment

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}{...