Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

Linux command structure

Previously we looked at simple terminal commands like ls, cd. We know that ls simply outputs all files in working directory. But in practice command without options and parameters is almost useless. In more complex situations you may need to list special files, or list files from specific directory without going to it. This is why UNIX commands are run with options and parameters

command [options] [parameters]

There can be more than one option and parameter for single command. For instance we used a cd .. command to go to previous directory. Dots .. are nothing more than parameters. Lets see what parameters we have with ls command.

ls -l

it displays list of files in long format. You can see that we get much more information by ading simple option -l.


Lets say we want to display files in long format from different than working directory. Then we need to type in path to directory as parameter.

ls -l /usr

ls command can go with several options. Additionally we can include -a option which will show files where name starts with period (hidden). So we can write:

ls -l -a

or same is

ls -la


Here is how to understand long file list:

drwxr-xr-x 2 	pi 	pi 	4096 	May 25 20:47 Desktop
-rw-r--r-- 1 	pi 	pi 	5781 	Feb  3 07:07 ocr_pi.png
drwxrwxr-x 2 	pi 	pi 	4096 	Mar 10 12:20 python_games
--------     -------  -------  -------- ------------ -------------
   |             |        |         |         |             |
   |             |        |         |         |         File Name
   |             |        |         |         |
   |             |        |         |         +---  Modification Time
   |             |        |         |
   |             |        |         +-------------   Size (in bytes)
   |             |        |
   |             |        +-----------------------        Group
   |             |
   |             +--------------------------------        Owner
   +----------------------------------------------   File Permissions

Couple handy default programs that can be helpful. First one is called less. It is used to view text file contents. Navigating is done with Page Up and Page down buttons. Type

less –help

for more controls

Another handy program is called file. It helps to detect file type. It looks at file and tells what it contains. For instance we can run

file ocr_pi.png

It displays that file is PNG, 48×48 size and 8 bit color RGBA.


I bet this information can be used in automated scripts when doing file processing.

This is by far not all that can be done with commands. Commands can be combined in to long command lines with pipes. So with single line you can do complex tasks that would normally take some programming. But lets leave this to later posts.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.