UCONN

UCONN
UCONN

Linux explained

Linux


When we talk about Linux we first must understand its origins and the UNIX operating system.


Unix was born in 1969.


AT&T's Bell Laboratories in the early 1970's.


The Unix operating system was conceived and implemented by Ken Thompson and Dennis Ritchie (both of AT&T Bell Laboratories) in 1969 and first released in 1970. 

Programming language, C, to make it portable. 

 

In 1977, the Berkeley Software Distribution (BSD) was developed by the Computer Systems Research Group (CSRG) from UC Berkeley, based on the 6th edition of Unix from AT&T. 


The 1960's "saw" people organizing groups and actively working for change in the social order along with the government


UNIX system code all began developing their own different versions.


Universities, research institutes, government bodies and computer companies are using the UNIX system to develop many of the technologies.

Vendors concerned about encroachment into their markets and control of system interfaces, developed the concept of "open systems."


In 1987, AT&T announced a pact with Sun Microsystems(Berkeley UNIX). 


Industry clubbed together to develop their own "new" open systems operating system, the Open Software Foundation (OSF). 


What is an Operating System?


An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.

 

Time-sharing operating systems schedule tasks for efficient use of the system and may also include accounting software for cost allocation of processor time, mass storage, printing, and other resources.

 

Linux began in 1991 as a personal project by Finnish student Linus Torvalds: to create a new free operating system kernel. 



In 1983, Richard Stallman started the GNU project with the goal of creating a free UNIX-like operating system.


https://www.gnu.org/home.en.html

GNU's not Unix


As part of this work, he wrote the GNU General Public License (GPL). 

The GNU General Public License is a free, copyleft license for software and other kinds of works.

GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. 

In 1985, Intel released the 80386, the first x86 microprocessor with a 32-bit instruction set and a memory management unit with paging.

 

The Operating System boots or brings up a kernel.

Linux is an operating system that allows users to control computers.

Kernel - Kernel manages hardware resources and acts as a bridge between other software components.


The kernel is the interface between hardware and software.
The user transmits commands to the kernel through the shell.


Open source - Denoting software for which the original source code is made freely available and may be redistributed and modified.

Distribution

A Linux distribution is a combination of software that comes with the Linux kernel and allows users to manage the operating system.

  • Ubuntu

  • RedHat

  • Debian

.

Shell

A shell is a program in which the user instructs the operating system by entering commands.

File

A file is the unit in a computer system where data is stored. 

Directory (Folder)

A directory is the unit in which files and subdirectories are organized. A directory can contain other files and subdirectories.


Tree Structure

Files and directories form a tree structure in computer systems.
At the top level, there is a root directory. 

Path

Addressing system used to specify the location of files or directories. The file path specifies the exact location of the file or directory.


 

Free - (for the most part)

When you login to a Linux system 

Access the Cloud Shell

 

 

In the upper right hand corner of the screen Click on >- symbol to activate the cloud shell.

 

Welcome to Cloud Shell! Type "help" to get started.

Your Cloud Platform project in this session is set to uconn-engr.

Use “gcloud config set project [PROJECT_ID]” to change to a different project.

john_iacovacci1@cloudshell:~ (uconn-engr)$ 


The prompt $ waits for you to type commands and also lists the random id given to your project unless when creating your project you give it a unique id.

 

 

 

Ctrl +c will always get prompt back

   

All Linux/Unix system have a superuser account called "root".

 

This account can change passwords, delete files and do everything on the system. Full permissions.

 

Linux is case sensitive and does not use spaces in file names.


A file system is necessary to store files on a computer.


The Linux file system starts with the root directory (like a tree)


and branches into subdirectories from the root.


Each sub-directory can have move subdirectories underneath so it is like an upside down tree.


E.g.


To create a directory you use the mkdir command


john_iacovacci1@cloudshell:~ (sentiment-analysis-379200)$ mkdir assignment1

john_iacovacci1@cloudshell:~ (uconn-engr)$ mkdir assignment1



The cd command allows you to move into that directory


john_iacovacci1@cloudshell:~ (uconn-engr)$ cd assignment1

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ 


Linux File System Directories.

/bin: Where Linux core commands reside like ls, mv.

/boot: Where boot loader and boot files are located.

/dev: Where all physical drives are mounted like USBs DVDs.

/etc: Contains configurations for the installed packages.

/home: Where every user will have a personal folder to put his folders with his name like /home/john_iacovacci1 (taken from my gmail login)

/lib: Where the libraries of the installed packages located since libraries shared among all packages

/root: The home folder for the root user.

/sbin: Like /bin, but binaries here are for root user only.

/tmp: Contains the temporary files.

/usr: Where the utilities and files shared between users on Linux.

/var: Contains system logs and other variable data.


The cron command-line utility is a job scheduler on Unix-like operating systems. Users who set up and maintain software environments use cron to schedule jobs, also known as cron jobs, to run periodically at fixed times, dates, or intervals.


The navigation commands

cd - is change directory

 

you can change directory to an absolute path e.g.


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ cd /home/john_iacovacci1/assignment1




Absolute path always begins with /


 cd ..

Brings you up one directory

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ cd ..

john_iacovacci1@cloudshell:~ (uconn-engr)$ 


Relative path allows you to change to a directory relative to where you currently are set to.

You can move into a directory using the cd command


john_iacovacci1@cloudshell:~ (uconn-engr)$ cd assignment1

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ 




Note: cd $HOME


Will take you to your home directory.

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ cd $HOME

john_iacovacci1@cloudshell:~ (uconn-engr)$ 


 

pwd - stands for print working directory - tells you where you are


john_iacovacci1@cloudshell:~ (uconn-engr)$ pwd

/home/john_iacovacci1



The touch command allows you to create a file


john_iacovacci1@cloudshell:~ (uconn-engr)$ cd assignment1

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ 

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ touch file1


ls - lists all files and directories within the working directory (or path you provided)


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ls

file1


Adding the -lt option for (for ownership and time stamp)


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ls -lt

total 0

-rw-rw-r-- 1 john_iacovacci1 john_iacovacci1 0 Aug 14 01:05 file1


Linux files have 3 sets of permission attributes

read(r), write(w) and execute(x) for owner, group and everyone

 

See how the file is permissioned.

 

chmod command can change the permissions of a file or directory


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ chmod +x file1

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ls -lt

total 0

-rwxrwxr-x 1 john_iacovacci1 john_iacovacci1 0 Aug 14 01:05 file1

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ 


To copy a file use the cp command


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ cp file1 file2


Use ls command to see the files


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ls -lt

total 0

-rwxrwxr-x 1 john_iacovacci1 john_iacovacci1 0 Aug 14 01:25 file2

-rwxrwxr-x 1 john_iacovacci1 john_iacovacci1 0 Aug 14 01:05 file1

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ 




echo is a command to repeat what you type


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ echo "Hello World"

Hello World


By default the output of commands go to the standard output or display screen


Redirection is a feature in Linux such that when executing a command, you can change the standard input/output devices.

 

Redirection allows you to redirect output to a file

 

The > symbol allows you to redirect output to a file


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ echo "Hello World" > file3

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ls -lt

total 4

-rw-rw-r-- 1 john_iacovacci1 john_iacovacci1 12 Aug 14 01:30 file3

-rwxrwxr-x 1 john_iacovacci1 john_iacovacci1  0 Aug 14 01:25 file2

-rwxrwxr-x 1 john_iacovacci1 john_iacovacci1  0 Aug 14 01:05 file1

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ 


cat is a command that display contents to a file


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ cat file3

Hello World


A wildcard allows you to use any command to pattern match to a file.

 

? - one character

* - all characters 

[] - range of characters

 

ls -lt file?

ls -lt f*

 

 

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ls -lt file?

-rw-rw-r-- 1 john_iacovacci1 john_iacovacci1 12 Aug 14 01:30 file3

-rwxrwxr-x 1 john_iacovacci1 john_iacovacci1  0 Aug 14 01:25 file2

-rwxrwxr-x 1 john_iacovacci1 john_iacovacci1  0 Aug 14 01:05 file1


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ls -lt f*

-rw-rw-r-- 1 john_iacovacci1 john_iacovacci1 12 Aug 14 01:30 file3

-rwxrwxr-x 1 john_iacovacci1 john_iacovacci1  0 Aug 14 01:25 file2

-rwxrwxr-x 1 john_iacovacci1 john_iacovacci1  0 Aug 14 01:05 file1

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ 


other file commands are

 

rm - remove a file

mv - move a file

mkdir - make directory

rmdir - remove directory

pwd — print working directory,

know which directory you are in, absolute path e.g. "/home/username".

ls — Use the "ls" files are in the directory you are in. ls -lt 

touch — command is used to create a file.

man --help — how to use command manual pages "man cd”

cp — copy files through the command line.

mv — move files 

locate — locate a file in a Linux system,

echo — repeats what you type.

cat — display contents of a file.

sudo — super user do allows you to act as root use.

df — see the available disk space 

du — know the disk usage of a file in your system.

tar — work with compressed files,

zip, unzip — compress files into a zip and unzip files

chmod — change the permissions granted to it in Linux.

hostname — know your name in your host or network.

“hostname -I” gives you your IP address in your network.

ping — Use ping to check your connection to a server. 

clear - clear the terminal,

grep  - command-line utility for searching plaintext.

find - allowed you to find a command on your system 

TAB can be used to fill up the terminal command..


Ctrl+C can be used to stop any comma

The UP Arrow calls up the last linux command so the user can execute it again by hitting return.



exit terminal by using the exit command.

 

 


https://www.shellscript.sh/


A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. 


Use the google editor to create a file


Highlight the directory you want to create the file in












Then right click on the directory to create a new file


Click on New file and enter hw.sh


First line provides path to the shell

Use echo command to display “Hello UCONN World”



#!/bin/bash

echo "Hello UCONN World"


Go back to Open Terminal


Make the file executable


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ chmod +x hw.sh


Then execute using ./ to specify where the file to be execute is


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ./hw.sh

Hello UCONN World


Now lets talk about variables.


A variable allows programs to store values and assign those values to a name.


We can use the shell read command to read the input from the terminal and assign the value inputted to a variable. Then we can use the echo command to display the value of that variable.



name.sh

#!/bin/bash

echo "Enter your full name : "

read my_name

echo "My Name is : " $my_name


john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ chmod +x name.sh

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ./name.sh

Enter your full name : 

John Iacovacci

My Name is :  John Iacovacci

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ 


We can redirect the standard output to a file using the > sign.

Note: the > creates a new file and the >> sign appends data to file.

====================================================

#!/bin/bash

echo "Enter your full name : "

read my_name

echo "My Name is : " $my_name > my_info.txt

====================================================

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ./name.sh

Enter your full name : 

John Iacovacci

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ cat my_info.txt

My Name is :  John Iacovacci

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ 


Assignment one - create a directory under your home directory called scripts and create a file called my_profile

 

 

1. pwd

 

should be home/user_name

 

2. mkdir scripts

 

3. cd scripts

 

4. pwd - /home/user_name/scripts

 

5. Use the terminal editor to access the graphical editor

 

6. Position cursor on the directory that you wish to create the file in


 

7. Right click the mouse and select New File 


 

8. Name the file profile.sh


 

9. Enter the commands into the file

 

#!/bin/bash

# My First scripts

echo "Enter your full name : "

read my_name

echo "Enter your major : "

read my_major

echo "Enter the year you will graduate : "

read my_graduation

echo "My Name is : " $my_name > my_profile.txt

echo "My major is : " $my_major >> my_profile.txt

echo "I will graduate in the year : " $my_graduation >> my_profile.txt

 

10. Go back to the Cloud Shell Terminal

12. Change the properties of the file so it can be executable

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ chmod +x profile.sh

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ ./profile.sh

Enter your full name : 

John Iacovacci

Enter your major : 

Computer Science

Enter the year you will graduate : 

2028

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ cat my_profile.txt

My Name is :  John Iacovacci

My major is :  Computer Science

I will graduate in the year :  2028

john_iacovacci1@cloudshell:~/assignment1 (uconn-engr)$ 


Download the file to a local directory


Click the 3 dot’s located near the Open Editor button



Click Download


Click folder to locate directory where file is located


Click arrow to expand directories



Click arrow next to directory where file is located



Select file

Click Download


File will appear in your local downloads directory



Copy code and attach file

Use paper clip to attach file


No comments:

Post a Comment

Disable Billing

Search for Billing Manage billing accounts Go to MYPROJECTS CLICK ON THE 3 BUTTON Actions Then hit disable