Linux 101 Training Module Linux Basics
This presentation will cover the following topics in Linux OS User and groups Logging into File System Commands File viewing commands
Users Groups , Root Access to Linux is based on users and groups Each user has a password and belongs to one or more groups. Group information is stored in the /etc/group file. The groups command displays the user's groups.
Logging Into Login from Putty Enter the IP address and port At the login prompt enter the following Login as : <ctrainee> <ctrainee>@192.168.13.129's password:<pwd> After successful logging : [ctrainee@cavisson-server ~]$
File System / bin usr lib home etc tmp sbin dev | netstorm ctrainee work scripts bin
File System /bin Essential user command binaries (for use by all users) /etc Host-specific system configuration /home User home directories. This is where you save your personal files /lib Essential shared libraries and kernel modules /usr /usr is the second major section of the filesystem. /usr is shareable, read-only data. /var /var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files. /proc System information stored in memory mirrored as files.
Commands ls List Files cp Copy Files mv Rename rm Delete cd Change directory pwd Print current directory mkdir Create directory rmdir Delete directory
Ls command ls – List of directory contents ls ls –l adf etc pdf scenarios testcases webapps ls –l rw-rw-r-- 1 netstorm netstorm 2588 Aug 4 10:59 README drwxr-xr-x 6 netstorm netstorm 4096 Aug 4 10:59 samples
Permissions Link Users Group Size Date Directory or file -rw-rw-r-- 1 netstorm netstorm 47182 Oct 7 06:216 abc.txt file permissions – 12 bits (4 octal values) Uppermost 3 bits – suid(4), sgid(2), sticky (1) Next 3 bits – user read(4), write (2), execute (1) Next 3 bits – group Next 3 bits -- others
Read permission. Regular file : file can be opened and read. Directory : list the contents of the directory. Write permission. Regular file : file can be modified ,write new data. Directory : can add, remove, and rename files in the directory. Execute permission. Regular file : execute file as a program or a shell script. Directory : to access files in the directory and enter it, with the cd command
cp - copy files and directories Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. cp source.txt dest Copies source.txt to dest dir
mv Moving and renaming moving or renaming files. $ mv file file2 If file2 doesn't exist, it'll be created, but if it exists, it'll be overwritten
rm removes files or dir Removes file rm file Forcefully removes file from the system rm –f abc.txt
cd change directory changing directory to ab cd ab prints the current directory pwd /home/ctrainee
mkdir & rmdir mkdir – make directory abc mkdir abc Rmdir – remove directory abc rmdir abc
File viewing commands Cat Tail More Grep
cat command cat - concatenate files and print on the standard output $ cat xtest #!/bin/bash Y=`cat /etc/build_num` echo $Y Y=`expr $Y + 1`
Tail Command tail - output the last part of files tail webapps/logs/TR1001/summary.report Test Case Name: tests Test Run Number: 1001 Test Started At: 9/27/12 09:26:11 Test Configuration
more command More is a filter for paging through text one screenful at a time For example, more out.log
grep command Searches the given file for lines matching the given strings or words. Search /etc/passwd for boo user: $ grep boo /etc/passwd