Top Banner
Review Please hand in any homework and practicals Vim Scripting Inter-device communication
26

Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Jan 17, 2016

Download

Documents

Sheena Fox
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Review

Please hand in any homework and practicals Vim Scripting Inter-device communication

Page 2: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Today

Folders review Paths review Services Processes

BE SAFE TOMORROW May Day, May 1st

Check your schedules, no class after 5pm

Page 3: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Directory StructureLinux is a ‘tree’ or ‘hierarchical’ directory structure (so is

Windows)

http://www.linux4windows.com/Articles/linux_directory_structure.png

Page 4: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Paths Again The relative path has to reflect our new position Where We Are Relative Path /home/tom/documents text /home/tom (~) documents/text /home tom/documents/text

Does ‘Where We Are’ look familiar? It’s the Absolute path Why?

Page 5: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Full Linux Directory Structure

Page 6: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Directories This is why paths are important (abs vs relative)

You need to know where you are and where you need to go to

/bin, /sbin, /usr/bin, /usr/sbin All contain commands (programs/executables)

/dev Short for ‘devices’ – hard drives, usb, cd/dvd, etc…

/etc Config files for the system – we’ve already seen sudo

& passwd files, also has web browser, groups, logging, program config files, etc…

Page 7: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Directories, pt 2 /home

Holds user files (akin to the folder that holds ‘My Documents,’ ‘My Music,’ ‘My Pictures,’ etc… in Windows)

/tmp Temp directory, used to store temporary files Always the first directory to get deleted – don’t store

files here and expect them to stay /var

Directory that holds ‘variable’ files that change during the normal running of a system

Log files in /var/log/messages (logs get added, etc…); email (/var/spool/mail); webserver/ftp

Page 8: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Misc Directories Those are the directories you should get to

know first Others are for more advanced topics/functions: /boot – holds the ‘live’ kernel /lib – library files for kernel, updates,

programming, etc… /root – root user’s home dir /opt – folder for 3rd party applications /usr – files shared between users And more

Page 9: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Paths And Access Useful administration tasks

Checking /tmp Viewing configuration files/settings Creating and running scripts Moving around

Looking through processes

Page 10: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Scenario 1 We want to look for failures on a device Login Check log (permissions locked) Escalate privileges Check log again

<demo>

Page 11: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

For Those Viewing Later Login: student

Password:

[student@it136centos65vm ~]# cat /var/log/messages

Error: permission denied

[student@it136centos65vm ~]# su ndillon

Password:

[ndillon@it136centos65vm ~]# sudo cat /var/log/messages | grep error

Password:

Page 12: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Scenario 2 Setting/changing a static IP

Google Log in Escalate Vi …and the new thing for today… Restart the ‘service’

Page 13: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

For Those Viewing Later Google ‘linux set static ip’

/etc/sysconfig/network-scripts/ifcfg-eth0

Login: student

Password:

[student@it136centos65vm ~]# su ndillon

Password:

[ndillon@it136centos65vm ~]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 backups/

[ndillon@it136centos65vm ~]# sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

Inside vi, set IPADDR, BOOTPROTO, MASK, GATEWAY, and save and quit

[ndillon@it136centos65vm ~]# sudo /etc/init.d network restart

[ndillon@it136centos65mv ~]# ip eth0

Page 14: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Summary 1) Know what you’re doing

Modifying a config file? Checking system resources?

2) Know what resources you’re working with And where they are IP address? Files? /tmp? HDD (SAS/SATA or IDE)?

3) Have a good tutorial Different tutorials will explain it different ways Figure out which ways work best for you (graphical,

text, video, etc…)

Page 15: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Questions on Paths?

When you log into a system you’ll be in /home/<username>

From there you can access things through the relative path or through the absolute path

Page 16: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Processes and Users A process is an action or job for the computer to

do Either persistent (goes on for a while – ‘run a

shell’), or immediate (‘list the files in this directory’ = ls)

When the first is run, the shell is started, and stays there until we force it to exit

In the second, the ls is run and it’s done The ps command shows the processes running

on the system at that exact moment

Page 17: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Most PS instances ps –ef flags help show: UID = user who started the job/process PID = process id (this is used with other

commands to specify a process to manipulate) TTY – tons o'fun here – this is the ‘space’ in the

system allotted to the specific user Time – the time the command was entered Command – the command (with options) that is

currently running LOT of info (will scroll off the screen)

Page 18: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Output of ps

From liquidweb.com

Page 19: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

We can see what's running

And we can see it live! The top command shows the 'top' running

processes Lots more useful info And live, not just snapshot like ps But also not to stdio (use q to quit) This means its not useful in scripts

Page 20: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Top Snapshot

(from: wikipedia article for top)

Page 21: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Top Output Type in top Changes live, use the ‘q’ button to quit Shows system information at the top – procs,

memory, utilization, and more Then shows live snapshot of system PID = process ID, each process gets a number,

numbers reset each boot, and increment (first process gets 1, second gets 2, third gets 3, etc)

Username = shows the user that started, and is running the command/utility

Nice = priority Command = what was run to kick this off

Page 22: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Processes Review What is a limitation of the ‘top’ command?

What does ‘top’ show that ‘ps’ does not?

When is ‘ps’ more useful?

Page 23: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Service A service is a full application So far we’ve done things that have used single

processes One running instance of the bash shell One running instance of ps

Services are commonly used applications that usually encompass more than one process

Networking: IP address, ports, communication streams, etc…

Page 24: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Manipulating Services Services are controlled through the service command

[ndillon@it136centos65vm ~]# sudo service ssh start

If the SSH service is not running, it will start it If it is running, nothing will happen

[ndillon@it136centos65vm ~]# sudo service network stop

Will stop all network services (no internet connection of any kind)

[ndillon@it136centos65vm ~]# sudo service apache restart

Will stop and then start the Apache web server If Apache is off, it will just start it again

Page 25: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Question on Services

Questions?

Page 26: Review Please hand in any homework and practicals Vim Scripting Inter-device communication.

Own Study

Folders review Sobell Ch 4 – The Filesystem (81-89)

Paths review Sobell Ch 4 – The Filesystem (81-89)

Processes Sobell Ch 8 – The Bourne Again Shell (323)