Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Week 2: Users and Groups, Managing

Resources
CIS 341 AB1

Carl A. Janzen
Fall 2016

Contents
1 Introduction 2
1.1 Review from last class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Managing Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Wrap-Up 5
2.1 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1 Introduction
1.1 Review from last class
Review
This is only an introduction to these topics. Throughout the course we will delve into more
details in all of these areas.

Find your way around: list directories, show file contents, find files in subdirectories or
locatedb, and search for pattern matches

Get help: accessing man and info pages, find related commands using apropos, access
package supplied documents in /usr/share/doc as well as online resources such as tldp

Type less: use history and tab completion features to reduce your typing load

Edit files properly: begin to use the most common vi commands to edit text files

I/O redirection: use pipes, fifos, the tee command, redirect standard error and standard
output, and record your session using script, ttyrec, or termrec

Checking file contents and paging: use tail, head, less, and wc to view or summarize
all or part of a text file

File management: change directories, print current directory, create and delete files
and directories, display a directory tree structure, and create links including symbolic
links

Permissions: modify and interpret permissions to permit or prevent reading, writing,


or execution/listing of files/directories and use the setgid bit and the chgrp command
to enable collaboration in a shared directory

Remote access: generate a public/private keypair and use it to authenticate to a remote


system

Remote file management


scp use ssh to copy files

rsync use ssh (if necessary) to copy only the differences between two locations (optionally
deleting)

sftp/lftp expose ftp/scp functionality in a convenient commandline ftp client interface.

git version control for software projects.

2/5
Windows
screen venerable console window manager, available on almost any system. Allows you to have
multiple windows, including split screen

tmux modern re-write of screen. Very similar key bindings, except they are all preceded by
Ctrl+B instead of Ctrl+A

1.2 Accounts
Become root
sudo sanitize environment, and run single command as root user

su switch user (by default, to become root, but can also be used to become other users)

Manage users and groups


users Stored in /etc/passwd has account info, and shadow file has more restricted access to
password hash

groups Stored in /etc/group, user can belong to multiple groups

1.3 Configuration
Setting defaults
/etc/skel Default settings for all users

.bashrc runs every time bash starts a shell / subshell

.profile runs only on interactive login shells (see also .bash_profile)

umask sets default file creation mask

PS1,PS2 set custom prompts

Configuration Files
dotfiles it is customary for config files and directories to start with a dot

dotbot (github project) one of numerous utilities avaialable for quickly configuring a new
account

1.2 Accounts 3/5


1.4 Managing Resources
processes
kill will let you send one of several signals (ie, SIGHUP, SIGUSR1, SIGTERM) to
any job by process id
killall will allow you to do the same by name
jobs are placed in the background when followed by a & symbol
Ctrl+Z will suspend the current job
fg will bring jobs back from the background
jobs will list all running jobs in the current shell
ps can list more process details, depending on your permissions
top shows a live updated process list (see also htop)
nohup prevents SIGHUP (hangup) from being sent to a background process when you
exit the shell
renice lets you set the priority of a process. -20 is least nice (highest priority) and 20
is most nice (lowest priority)

hardware
lspci -vv list pci bus details. Useful for listing your hardware (see also lshw)
/proc/cpuinfo cpu description
/proc/meminfo ram description
vmstat summary of allocated memory resources
free shows available ram
/dev device filesystem

network
netstat -pant list connections
ping verify connectivity
traceroute verify hops to destination
dig get detailed information about an address
tcpdump inspect network traffic (see also ettercap/wireshark)
route -n show active routes [ip] show/manipulate routes, addresses, etc

1.4 Managing Resources 4/5


scheduled jobs
crontab /etc/cron.d contains config files that allow you to allow/deny use of crontab (sched-
uled recurring jobs)

at run a job at a specific time

atq, atrm list, delete at jobs.

batch run a job when system load drops below 0.8 (see load)

2 Wrap-Up
2.1 Review
Remote file management: scp, rsync, git, sftp/lftp

Windows: screen, tmux

Become root: su, sudo

Manage users and groups: id, {add|mod|del}user, {add|del}group, user{add|mod|del}

Setting defaults: /etc/skel, .bashrc, .profile

Configuration Files: dotfiles

processes: kill, killall, gps, top, jobs, nice

hardware: lspci, cpuinfo, meminfo, vmstat, free, /proc, /dev

network: netstat, ping, traceroute, dig, tcpdump, route

scheduled jobs: crontab/permission for, at, atrm, atq

2.2 Homework
Homework
Assignment 1 posted

5/5

You might also like