Null/Shell

From XPUB & Lens-Based wiki
Revision as of 15:44, 18 November 2015 by Castrobot (talk | contribs) (Created page with "=Living in a Shell= Unix like OS are multi-user system, allowing a number of users to be login in at the same time, performing different tasks, but also to communicate with e...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Living in a Shell

Unix like OS are multi-user system, allowing a number of users to be login in at the same time, performing different tasks, but also to communicate with eac hoter


  • shell / terminal
  • multi-user session
  • access another machine: ssh
  • communication among users
  • ASCII art
    • figlet
    • jp2a
  • (text to speech)
  • raw printing




Shell Cheat Sheet

$ cd - change directory

$ pwd - print working directory

$ ls - list directory

$ rm - remove file or directory

$ cp - copy file or directory

$ mv - move or change name of file or directory

$ cat - concatenate print they content

$ echo - repeats what is written after

meta characters

Meta Characters are characters that have special meaning within the terminal

  • ~ the tilde stands for the user's home. cd ~/ change directory to home
  • . dot stands for this directory. ls . list this directory
  • .. dot dot stands for the parent directory to this directory. cp myfile.jpg .. copy myfile.jpg to the parent directory
  • * asterisk is a wildcards which represents zero or more characters ls P*.jpg will list all the files, in the current directory, that begin with P and end with .jpg
  • \ backslash it is a literal character. It escape the meta value of the meta-characters and display them only as literal characters. echo Foo \* will output Foo * If \ wasn't there it would output all the files in that directory.

man pages

man pages are manuals of program. They tells you what the program is, what it can do and how.

$ man df show the manual for the program df that is used to display the free disk space

Can you find out how to display the output from df in a human readable format?


pipe

A pipes (" | ") sends the output of one program to the input of another program.

$ echo "my sentence"| wc the echoed sentence "my sentence" is pipped into the program wc which counts the number of lines, words, and characters

write

> Writes the output of a command to a file, rather than to print on terminal.

man df > df_output.txt redirect the content of man dfM to a file called df_output.txt

If the said file doesn't exit it will create it, if it already exists it will overwrite its contents/

append

>> appends the output of a command to a file, without overwriting the original file. echo 'also add this' >> df_output.txt will add 'also add this' to the contents of df_output.txt

==package managers==
Package managers like apt and aptitude (on Debian/Ubuntu Linux distributions) and Homebrew and MacPorts on Mac, allow more (command-line, but not only) programs, than the ones that come with the operating, to be installed on our system.

Will need to install 2:
* figlet - A program to make large titles our of ASCII characters
* imagemagick - The swiss army knife for image manipulation on the command line


== Challenges ==
* You need to use '''figlet''' to print words and sentence on the terminal as large titles

* Using Wget and imagemagick you need to 
** Download an image from the web without using the browser to download the image, but the '''wget''' program
using imagemagick's '''display''' program display the image
** using imagemagick's '''display''' program display the image, but flipped and monochrome
** using imagemagick's '''convert''' program the image to monochrome and to a different file extension.

references