We briefly discuss some of the frequently used commands used in Ubuntu.
Changing Directory
The command for changing directory is cd
.
You can go to the top of your file system by typing
cd
. Any directory change starting with / will be relative to the top directory in the file system. Typing
cd folder/subfolder
, etc. will change directory relative to were you are now in the filesystem (the working directory), so, for example, if you are in the home directory, and you type directory home/arduino, but if you had instead typed cd arduino
you will go into the cd /arduino
, Linux would have tried to put you in an arduino directory at the top level of the file system (similar to C:\arduino on windows), which on most systems won’t exist.
Listing Files in a directory
To do this, type ls
.
This function ‘lists’ all the files in a directory. Adding -a
to the command ( ls
any hidden files in that directory. Adding -l
( ls -a
) will also show -l
) will show the file’s permissions, type, owner and the date it was created/edited.
Change User
On the Ubuntu system, we can use command su
to switch to root user mode. As many commands require root privilege, we can add su
to the beginning of the command.
root is the super user (administrator) on Linux. sudo
is the command which allows other users to issue a command as the super user. sudo
= “super user do”. Operations that a normal user aren’t normally allowed to do can be done using sudo. The word is just a mash of super-do and pseudo. USE SUDO WITH CAUTION! sudo
can be used to do a lot of damage to your system, and there is often a reason your normal account isn’t allowed to perform a certain action. sudu rm -rf /*
would completely delete everything in the filesystem, destroying the system.
Install Software Package
Apt-get is the package or software manager on Debian/Ubuntu linux. Install is the operation for apt-get to perform and the name of the package follows the keyword or action of install. Multiple package names can be put on the line following install. For example:
sudo apt-cache search vim #search the package named vim sudo apt-get install vim # install vim
Compress and Uncompress Install Software Package
Tar is a very popular file format in Linux to zipped files. The biggest advantage is that it can uses little CPU resources to zip files. It is only a packing utility, and it is not responsible for compression. The compression is done by gzip and bzip2. Now let’s use file format .tar, .tar.gz, and *.tar.bz2 as examples:
If we want to compress and pack the directory test under /var/tmp to the current directory,
tar -cvf test.tar test
The above command only packs directories and files, and doesn’t do compression.
tar -zcvf test.tar.gz test
The above command packs directories and files, and then compresses the pack using gzip.
tar -zcvf test.tar.gz test
The above command packs directories and files, and then compresses the pack using bzip2.
The following command compares the size of different resulting files:
ll test.tar*
-rw-r–r– 1 Lee mock 10240 01-18 17:05 test.tar
-rw-r–r– 1 Lee mock 357 01-18 17:06 test.tar.bz2
-rw-r–r– 1 Lee mock 327 01-18 17:05 test.tar.gz
How to uncompress the files:
tar -xvf test.tar tar -xvf test.tar.gz tar -jxvf test.tar.bz2
How to Uninstall / Delete / Remove Package
To uninstall package, we can use dpkg –list
to list all the installed software packages. Once found out the installed packages, we can use sudo apt-get –purge remove command followed by the package name to remove a certain package. For example:
sudo apt-get --purge remove lighttpd
A recommended text editor
Nano or vim are recommended for text editor. To install it, run: $sudo apt-get install nano
.
How to check kernel version
The following command is used to find out the version of kernel:
cat /proc/version
Linux version 3.4.39 (yao@linksprite) (gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-11ubuntu1) ) #1 SMP PREEMPT Thu Dec 24 10:52:34 CST 2015
Find CPU Information /Speed
You use the following command to display all information about the CPU: cat /proc/cpuinfo
Processor : ARMv7 Processor rev 5 (v7l) processor : 0 BogoMIPS : 4800.00
processor : 1 BogoMIPS : 4800.00
processor : 2 BogoMIPS : 4800.00
processor : 3 BogoMIPS : 4800.00
processor : 4 BogoMIPS : 4800.00
processor : 5 BogoMIPS : 4800.00
processor : 6 BogoMIPS : 4800.00
processor : 7 BogoMIPS : 4800.00
Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xc07 CPU revision : 5
Hardware : sun8i Revision : 0000 Serial : 203000f08100a4f40825
How to check storage space left
To check space left, type: df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk0p3 7.3G 1.8G 5.3G 25% /
none 436M 4.0K 436M 1% /dev
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 437M 4.0K 437M 1% /tmp
none 88M 2.7M 85M 4% /run
none 437M 0 437M 0% /var/tmp
none 437M 548K 437M 1% /var/log
none 5.0M 0 5.0M 0% /run/lock
none 437M 0 437M 0% /run/shm
none 100M 0 100M 0% /run/user
How to get the thermal of CPU
To get the thermal of CPU, type:
cat /sys/class/thermal/thermal_zone0/temp
Leave a Reply
You must be logged in to post a comment.