More Raspian. An editor Configuration files Shell scripts Shell variables System admin

Similar documents
Linux Systems Administration Getting Started with Linux

Introduction to the shell Part II

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Review of Fundamentals

The Unix Shell & Shell Scripts

Using bash. Administrative Shell Scripting COMP2101 Fall 2017

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Network softwarization Lab session 2: OS Virtualization Networking

9.2 Linux Essentials Exam Objectives

Adafruit's Raspberry Pi Lesson 6. Using SSH

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Sit with your new teammate

commands exercises Linux System Administration and IP Services AfNOG 2015 Linux Commands # Notes

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

5/20/2007. Touring Essential Programs

Lecture 4. Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions?

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala

Introduction: What is Unix?

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

CSE 390a Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

Post Ubuntu Install Exercises

Essentials for Scientific Computing: Bash Shell Scripting Day 3

LOG ON TO LINUX AND LOG OFF

Linux Command Line Interface. December 27, 2017

Log into Linux Reminders: Homework 1 due today; Homework 2 due on Thursday Questions?

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

Linux Essentials Objectives Topics:

Shell Start-up and Configuration Files

INTRODUCTION TO LINUX

Using echo command in shell script

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Linux Command Line Primer. By: Scott Marshall

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

D. Delete the /var/lib/slocate/slocate.db file because it buffers all search results.

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

LING 408/508: Computational Techniques for Linguists. Lecture 5

IBM AIX Basic Operations V5.

Part 1: Basic Commands/U3li3es

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Using RANCID. Contents. 1 Introduction Goals Notes Install rancid Add alias Configure rancid...

System Programming. Unix Shells

Introduction To. Barry Grant

Some Ubuntu Practice...

Environment Variables

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

Shell Programming (bash)

Linux 系统介绍 (III) 袁华

Unix Tutorial Haverford Astronomy 2014/2015

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

COMS 6100 Class Notes 3

CS 460 Linux Tutorial

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

Perl and R Scripting for Biologists

Aliases are set manually or in a login script. Aliases that were set manually will be gone the next time you login.

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009

CSE 391 Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

unix intro Documentation

Introduction to Linux

Linux Kung-Fu. James Droste UBNetDef Fall 2016

Ubuntu Practice and Configuration Post Installation Exercises interlab at AIT Bangkok, Thailand

Vi & Shell Scripting

Introduction of Linux

Lab 3a Using the vi editor

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

The kernel is the low-level software that manages hardware, multitasks programs, etc.

Network Monitoring & Management. A few Linux basics

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

TECH 4272 Operating Systems

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Exercise sheet 1 To be corrected in tutorials in the week from 23/10/2017 to 27/10/2017

Introduction to Linux for BlueBEAR. January

Traditional Access Permissions

bash startup files Linux/Unix files stty Todd Kelley CST8207 Todd Kelley 1

CSE 303 Lecture 4. users/groups; permissions; intro to shell scripting. read Linux Pocket Guide pp , 25-27, 61-65, , 176

bash Scripting Introduction COMP2101 Winter 2019

Assignment clarifications

Communication protocols and services

Assume that username is cse. The user s home directory will be /home/cse. You may remember what the relative pathname for users home directory is: ~

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Introduction to Linux

CSE 390a Lecture 3. Multi-user systems; remote login; editors; users/groups; permissions

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

CMU MSP Intro to Hadoop

Exploring UNIX: Session 3

HANDS UP IF YOU DON T HAVE A VM OR IF YOU DON T REMEMBER YOUR PASSWORDS. Or something broke

Linux. An introduction. Aurélien Villani 01/2018

Environment Variables

CS370 Operating Systems

Chapter 9. Shell and Kernel

Sub-Topic 1: Quoting. Topic 2: More Shell Skills. Sub-Topic 2: Shell Variables. Referring to Shell Variables: More

15-122: Principles of Imperative Computation

Introduction to Linux

Chapter-3. Introduction to Unix: Fundamental Commands

Everything about Linux User- and Filemanagement

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

CS CS Tutorial 2 2 Winter 2018

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1

Transcription:

More Raspian An editor Configuration files Shell scripts Shell variables System admin

Nano, a simple editor Nano does not require the mouse. You must use your keyboard to move around the file and make changes. Can be used in a ssh connection. nano uses control-key commands. For example, to exit nano, press and hold ctrl x (depress the control key and x at the same time) When running, nano shows a list of important control keys at the bottom of the screen. To view a complete list, press ctrl G, or press the F1 key. To start nano, type: nano at the terminal prompt To save the changes to a file press ctrl o to save the file and ctrl x to quit. You can also edit files using vi or Leafpad (on the Desktop) or install a new editor using apt-get install I recommend emacs---very powerful, but a big learning curve.

Configuatin Files Remember the command, sudo raspi-config raspi-config is actually a user-friendly front end to the config.txt configuration file located in the /etc directory Linux applications use configuration files to manage settings. For system applications they are typically located in /etc. Try listing (ls) that directory Some are in directories, and often have a.conf extension Always invoke sudo to edit a configuration file located in the /etc directory Try sudo su to switch to being the adminstrator

Customize your shell A login shell is a bash shell that is started with - or --login. The following are examples that will invoke a login shell. sudo su - bash --login ssh user@host When BASH is invoked as a login shell, the following files are executed in the order listed /etc/profile ~/.profile Although ~/.bashrc is not listed here, most default ~/.profile scripts run ~/.bashrc Edit.bashrc to define a new prompt and introduce a few aliases PS1= hello class: Remove the # (comment marker) on the following lines: alias ll='ls -l' alias la='ls -a' alias l='ls -CF'

Shell scripts raspi-config is actually a Bash shell script (Linux script files typically have the file extension.sh) The raspi-config script is located in /usr/bin Create a simple script named myscript.sh in your home directory From Teach Yourself VISUALLY Raspberry Pi Type chmod 755 myscript.sh to change the permissions on the script so it can run

Changing your PATH Try running the script, type myscript.sh at the prompt It doesn't run; now try:./myscript.sh The current directory is not in your PATH Type nano.bashrc.bashrc is a configuration file for the Bash shell Add the following line to the end of the file & save: PATH=$PATH:$PWD This line tells the Bash shell to look for scripts in your current directory. Type source.bashrc to apply your new PATH variable to the current environment Try running the script The script finds the filename you specify when you run it, and then stops

Shell Variables and more Shell Programming Enter the cammand: env to see the active environment variables Type: export VARIABLE="SOMETHING" and run env again Shell script command-line arguments are reffered to using positional parameters $1, $2, $3,... up to $9. Shell programs are made of commands, variables, and control structures Conditional Looping

Conditional (for the bash shell) Form: if [ <TEST> ]; then DO SOMETHING fi Example: if [ $number % 3 -eq 0 ]; then echo "Fizz" fi

Loops Form: while [ TEST ]; do DO SOMETHING done Example: #!/bin/bash c=1 while [ $c -le 5 ] do echo "Welcone $c times" (( c++ )) done

An Example #!/bin/bash trap 'echo Thank you for playing' EXIT magicnum=$(($random%10+1)) echo 'Guess a number between 1 and 10:' while echo -n 'Guess: ' >&2 ; read guess; do sleep 1 if [ "$guess" = $magicnum ]; then echo 'Right!' exit fi echo 'Wrong!' done

System Admin The sudo command makes you (for that command only) the system administrator sudo su (switch users to be the administrator or root user) Add a new user account, type (all one command): sudo useradd -m -G adm,dialout,cdrom,audio,plugdev,users, lpadmin,sambashare,vchiq,powerdev <username> set a password on the new account, type sudo passwd <username> Updating, install & removing software sudo apt-get update sudo apt-get install <name> sudo apt-cache search <name> or sudo dpkg -get-selections > ~/Desktop/packages sudo apt-get remove <name>

More Sys Admin Tools Resource management: top free -m sudo df -h ps kill 9 <PID> Reading Information in /proc Everything you ever needed to know about the system state or running processes can be found in /proc CPU configuration, stored in /proc/cpuinfo memory usage, stored in /proc/meminfo File commands: find /mnt/volume1 empty name foobar exec rm grep, sed, awk...