Unix

¡Supera tus tareas y exámenes ahora con Quizwiz!

Jane Doe is a new contractor who will be joining your company May 1, 2005, to work on an Information Technology project and also to assist in some end-of-fiscal-year Human Resources work. Jane's manager has requested that you create an account for Jane, who will need access to the employees, info-tech-1, info_tech_2, and info_tech_5 groups. Her contract with the company ends 31 days from her start date. Create the account using useradd. Here's additional information you'll need: Standard users are created with an inactive account timeout of 10 days, and are assigned the Korn shell. A username (account name) is created using the person's first-initial-and-last-name combination (up to eight characters for the account name). In this company, all accounts have the employee name in the /etc/passwd file as well as a designation of E for full-time employees or C for contractors before the name, with one space between the designator and the employee name. The system uses the /export/home directory for home directories. Assign Jane's account the userid 1000 because the most recent account UID created was 999. You are already logged in as root.

# adduser -c "C Jane Doe" -d /export/home/jdoe -e 2005/05/31-f 10 -g employees -G info_tech_l, info_tech_2, info_tech_5 -m -s /bin/ksh -u 1000 jdoe # passwd jdoe Changing password for user jdoe. New UNIX password: Retype UNIX password: passwd: all authentication tokens updated successfully.

Appending to a file & % cat list1 list2 > biglist

% cat >> list1 pear banana ^D % cat list1 (list out contents) OR combining contents of list 1 and 2 and transferring to biglist.

% cp science.txt tempfile.txt % ls % rm tempfile.txt % ls

% cp science.txt tempfile.txt (create copy of science file and rename as tempfile) % ls (list out the files) % rm tempfile.txt (remove temp file) % ls (list out balance file which is just science file) rmdir is used to remove directory. MAKE SURE IT IS EMPTY FIRST.

How to search phrase 'spinning top' in science.txt file?

% grep -i 'spinning top' science.txt

Use the 'grep' command to search science in science.txt

% grep science science.txt (looking for the word science in science.txt file) grep is case sensitive. To ignore upper and lower case distinction, type % grep -i science science.txt

What is the diff b/w 'whoami' and 'who am i' command?

'whoami' shows who you are currently logged in as, whereas 'who am i' shows who you originally logged on to the system as.

explain the following: -v -n -c

-v (display those lines that DO NOT match. eg like sets venn diagram with ') -n precedes each matching line with line number -c print only total count of matched lines

Create a list of fruit under list1 using concatenate command

1. % cat > list1 (redirecting the output 2. type names of some fruits (pear banana apple ^D to stop command and reads the standard input and the > redirects the output which goes on screen into file called [type as ctrl + [d] ] % cat list1 Type % cat list1 to read the contents of the file

How do you search the word 'science' in a text file called 'science.txt' using the less command?

1. % less science.txt 2. /science Type [n] to search for the next occurence of the word

how to find no of words in science.txt file?

1. % wc -w science.txt (word count in file) 2. % wc -l science.txt (list no of lines in file)

1. -G 2. -m 3. -s 4. -u

1. -G = comma-separated list of supplementary groups to which user belongs [Field 4 of grps identified in command line] 2. -m = creates home directory if it doesn't exist [field affected NA] 3. -s = the user's shell for interactive logins [Field 7] 4. -u = Assigns user ID (unique unless -o option which allows duplicate UIDs [Field 3] Command structure is : useradd -c comment -d home directory -e expiration date -f inactive days -g primary(default) grp -G secondary groups -m -s shell -u user id accountname

1. -c 2. -d 3. -e 4. -f 5. -g

1. -c = comment for GCOS [field 5] 2. -d = account's home directory [field 6] 3. -e = expiration date of acct in yr-mth-day or vice versa [field 8] 4. -f = no. of days acct can be inactive before being disabled [field 7] 5. -g = initial group (default grp) [field 4]

What are the 3 main user administration files?

1. /etc/passwd - identifies the authorised accounts for the system 2. /etc/shadow - holds the encrypted password of the corresponding account. Most Unix systems have this file 3. /etc/group - contains information on group accounts

What are the three primary files that deal with user and group administration? What are they for?

1. /etc/passwd. Holds information concerning the account name, user ID, group ID, home directory, and shell. 2. /etc/shadow. Holds the encrypted password for the corresponding account name in /etc/passwd as well as password and account-aging information. 3. / etc / group. Identifies the different groups available for accounts.

What are some good practices for naming files & explain on using "program.c" as file name

1. Avoid special characters such as * & % 2. Avoid space in names. Use underscore_ instead and dot . 3. Use only alphanumeric characters typing ls *.c will list out all files ending with .c

What are the 3 major shells for Unix?

1. Bourne shell (sh) also called Shell 2. C shell (csh) taken from uni of california 3. Korn shell (ksh)

Categories in Manual Pages (man pages): 1. NAMES 2. SYNOPSIS 3. DESCRIPTION 4. OPTIONS 5. SEE ALSO 6. BUGS 7. EXAMPLES OR TIPS

1. NAMES - names of commands 2. SYNOPSIS - general usage parameters of the command 3. DESCRIPTION - describes the command and what it does 4. OPTIONS - describes all options to the command 5. SEE ALSO - lists other commands directly related to the command and other functions that has close resemblance 6. BUGS - explain any known issues or bugs 7. EXAMPLES OR TIPS - shows an idea how the command can be used

What are the 3 primary types of accounts on a Unix system?

1. Root user (or superuser) 2. system accounts 3. user accounts Root user can do anything on system without password even to the point of completely destroying the system. System accounts needed for operation of system-specific components. Any modifications could adversely affect the system. User accounts provide interactive access to systems for users and groups.

1. man pages 2. man command (syntax) man man

1. Used to access manuals or help files in Unix 2. Used to see manual page on the command 'manual'

How do you move the file science.bak to your backup directory using move command?

1. change dir to unixstuff % cd ~/unixstuff 2. % mv science.bak backups/ .

System shutdown commands: 1. init 0 2. init 6 3. halt 4. poweroff 5. reboot 6. shutdown

1. init 0 - powers off system and cleans it up prior to shutdown 2. init 6 - Reboots by shutting down completely and then reboots it completely back up Both not available in all Unix system 3. halt - Brings system down immediately (can cause possible data corruption) 4. poweroff - shut down by powering off 5. reboot - reboots system 6. shutdown - shuts down the system Preferred method is shutdown

% head science.txt % head -5 science.txt % tail science.txt

1. shows the first 10 lines of a file to a screen (10 lines are the default setting for the command) 2. shows the first 5 lines of a file Can also write as % head -n 5 science.txt 3. writes last 10 lines of a file

Explain the following: 1. shutdown -r 2. shutdown -h

1. shutdown and restart 2. shutdown by using the poweroff button to physically power it down safely

Explain the terms below for remote login to a Unix system: 1. ssh 2. telnet 3. sftp 4. ftp

1. ssh - logins interactively to the shell to perform multiple functions such as running commands. This method uses encryption 2. telnet - same as ssh but NO encryption 3. sftp - logs in to transfer files between two different systems. This method is encrypted 4. ftp - same as ftp but NO encyption good practice to use ssh (secure SHell) for encryption

1. useradd 2. usermod 3. userdel 4. groupadd 5. groupmod 6. groupdel

1. useradd - adds accounts to system 2. usermod - modifies account attributes 3. userdel - deletes accts from system 4. groupadd - adds groups to system 5. groupmod - modifies group attributes 6. groupdel - removes group from system

Diff b/w % ls list* & % ls *list

1. will list all files starting with list 2. list all files ending with list

What is the ? wildcard

? only match with one character eg % ls ?ouse can be house or mouse

% cd ~/unixstuff % cp /vol/ee/ee-info/Teaching/Unix/Science.txt .

Above means copy file "Science.txt" to current dir keeping the name the same. . at the end means current directory

What are Utilities?

Applications that enable you to work on the system (not to be confused with the shell)

explain 1. % sort < biglist 2. % sort < biglist > slist

Biglist contains list of fruits (apples oranges banana etc) the list of fruits in "biglist" is sort out alphabetically and being outputted in slist for part 2. % cat slits to see its contents with the sorted out fruit list

What is $

Command prompt start and end with the $ sign eg $ cal to show calendar

What is File system?

Enables users to secure, view and organise files and directories located in storage devices

A new temporary employee, Sarah Torvalds, has joined your company today (5/01/05). Sarah's manager has requested that you create an account for Sarah. She has joined the company to assist in some end-of-the-year human resources work, so she needs access to the default user group and to the hr group. Her contract with the company ends 120 days from her start day (the same day the account is created). Standard users are created with an inactive account timeout of 30 days, are assigned to the employees group by default, and are assigned the c shell. Usernames are created using the first initial and last name (no more than eight characters total for the account name, in this case for compatibility with other Unix systems). You need to create an account for Sarah using the useradd command because you do not have access to any graphical tools.

First log in as root, then run the following commands: # useradd -c "Sarah Torvalds" -d /home/storvald -e 05/01/05 -f 30 -g employees -G hr -m -s /bin/csh -u 1005 storvald # passwd storvald Changing password for user storvald. New UNIX password: Retype UNIX password: passwd: all authentication tokens updated successfully.

Group accounts

Group accounts add capability to assemble other accounts together in a logical arrangement. One of the strengths of groups is that an account can belong to many groups based on access requirements.

Where does virtual memory come in? What is the process called?

It comes in when a program requires more memory than what is already available. It is called Paging. It occurs when a program shifts part of the physical memory to the hard disk until that memory is needed again.

What is 'who' command used for?

It identifies who is currently logged in to the system.

What is Shell?

It is a command line interpreter that enables the user to interact with the operating system. Used directly to administer and run the system

What is the good thing about Shell?

It is good for shell scripting as its scripts are very portable across systems. But it has fewer features for user interaction as compared to other modern shells. There is also Bourne Again Shell (bash) which is a more revamped version of bourne shell. User use the SHell to control computer via commands and communicate to the kernel.

What is Swap Space in Unix? Why is it important?

It is the segment of the hard drive used for virtual memory. Running out of swap space can cause system failure.

Which layer of the Unix system is Kernel is? What does the Kernel do?

Kernel is the lowest layer. It controls processes, manage memory and allow programs to access hardware in an orderly manner. Most important function of kernel is to faciliate and manage processes. Manages CPU; OS of the system

beginningunix:x:510:500:Beginning Unix:/home/beginningunix:/bin/bash

Line divided into 7 file entry fields. Each entry must have all seven field but some fields can be blank 1. beginningunix [Login ID] 2. x [Encrypted password] 3. 510 [UID] 4. 500 [GID] 5. Beginning Unix [GCOS, comment but avoid sensitive info] 6. /home/beginningunix:/ [location of account's directory] DO NOT assign /tmp as home directory for any account because this can create serious security vulnerabilities 7. /bin/bash [user's login shell]

What is the difference between Paging and Swap?

Paging moves part of the process to hard drive but swap moves the entire process to hard drive space.

What are the main components of Unix?

Shell, Kernel, Utilities & File System

What is Swap?

The kernel identifies the least busy process or one that does not require immediate execution. It moves the entire process out of RAM to the hard drive until needed again.

Explain the following output when 'who' command is entered. beginningunix console Feb 8 22.18 beginningunix ttyp1 Feb 8 22.18 jdoe ttyp2 Feb 8 22.30 (192.168.2.1)

The output is in four columns: login name, terminal, login time and remote hostname or X display. Three users are logged in: beginniningunix twice and jdoe. The console is the terminal (screen display) as well as the ttypl and ttyp2, which are terminals (devices to identify what terminal the user is on). The next field identifies the date and time when each the user logged in, and you can see that jdoe came in from a remote connection (192.168.1.2).

What is a source code?

The source code represents the internal workings of a program, specifiying line by line how it works. This is diff as compared to commercial programs where they are in binary form instead of source code. This makes the internal lines unreadable by users but only allow them to run.

Create an account for a user named unixnewbie, whose real name is Jane Doe. Jane needs the account until July 4, 2006. Her primary group is users, and authors is her secondary group. She has requested the Bourne shell for her default shell. She isn't sure she will be using this system, so let's disable her account if she hasn't used it within 60 days.

The useradd command to create this account is: useradd -c "Jane Doe" -d /home/unixnewbie -e 040406 -f 60 -g users -G authors -m -s /bin/ksh -u 1000 unixnewbie After this command runs, a password to the account must be set using the passwd accountname command. To create the password for Jane Doe's account, root would type: passwd unixnewbie The new account owner should change the password immediately.

Explain 'usermod' command

The usermod command enables you to make changes to an existing account from the command line (instead of modifying system files). It uses the same arguments as the useradd command, plus the -1 argument, which allows you to change the account name. For instance, to change Sarah Torvalds' account name to saraht and provide her with a home directory, you'd issue the following command: usermod -d /home/saraht -m -1 saraht storvald This command changes Sarah Torvalds' current account (storvald) and makes the new home directory /home / saraht (-d /home/ saraht -m) and the new account name saraht (-1 saraht). The -m creates the home directory that hadn't previously existed.

What does the 2 commands 'su' and 'sudo' do?

They enable you to login to another account without logging out of the system. The su (switch user) command is available on all versions of Unix. It enables you to remain logged in as yourself while accessing another account. You must know the password for the account you are trying to access using su unless you are the root user, in which case you don't need a password (on the local system). Here's the syntax for su: su accountname If you are logged in as jdoe, for example, and want to log in as jsmith, type: su jsmith If you want to use the account's user environment, put a dash (-) between the su and the account name: su - jsmith The sudo (superuser do) command enables the superuser, or root administrator, to delegate commands that can be run by others. It is not available on all Unix systems. Here's the command's syntax: sudo command to run To list all the commands available for the user to run with sudo, type: sudo -1

What is 'whoami' command used for?

To identify what user you currently are. This happens when you switched user so much or login to many machines until forget.

Check who is on the system with you using piping command and w/o piping command

Wtih piping % who | sort [sort the names of who is on the system. Piping command shifts output of left column and make it as input of right column] Without piping % who > names.txt % sort < names.txt [system will be a bit slow and temp file 'names.txt' is created. Temp file to be removed after you finish

what is cd, cd . . & cd . & cd ~

cd . - stays in current dir cd . . - parent dir (one directory up) cd - home directory (no arguments) cd ~ - home directory ls /usr/local

$ clear

clears all text and leaves you with the % prompt at the top of the window

cp file 1 file 2

copies file 1 and names the copy in the current working dir as file 2

Explain the following: ssh darwin ssh 192.168.6.58

darwin is the host name (can be an actual name). The other is IP address. Used to connect remotely to a Linux system

mv (move) command mv file 1 file 2 Explain

file 1 is being moved or renamed to file 2

Use 'groupadd' to create a new group for the finance department called finance-2 and assign it a unique GID of 535

groupadd -g 535 finance-2 groupadd -g group-id group-name [syntax]

Use 'groupmod' to change the finance_2 group name to financial

groupmod -n financial finance_2 groupmod -n new-modified-group-name old-group-name [syntax]

% cat science.txt %cat science1.txt science2.txt % less science.txt

joins both files together and displays the content together (Concatenate) less command limits contents of the file to fit one page at a time. Press 'spacebar' to see next page and type [q] to quit reading.

% apropos copy

lists out comments with 'copy' keywords

What is the command for searching manual by key words?

man -k permissions - to see manual page on permissions or man -k shell

what is pwd

print working directory


Conjuntos de estudio relacionados

Chapter 5 Neuroanatomy, Neurophysiology, behavior and Neurotransmitters, receptors, activity

View Set

Medical Terminology TEST 1 chapter 2

View Set

Nclex purple book Antineplastic Meds

View Set

Econ 104- Final Exam (Professor Hendrik Van den Berg) umass

View Set

English 11B: Unit 2: Chapters 6-9

View Set

Networking - IP addressing: Classful addressing

View Set