|
|
|
|
Linux/Unix - Braindumps
Zurück
zu Braindumps zu Linux/Unix-Prüfung Nr. 117-101
Prüfung: Linux/Unix 117-101 LPI, Level 1, General Linux, Part 1
|
Alles von & über Linux/Unix!
Braindumps-Eintrag:
| Gepostet von: Anonymous | | Titel: summary of lpi 101 | | Datum: 26.04.2006 |
| This is summary from IBM material.
1.$ echo "good start"
good start
2.$ echo "good start"|start
it'll create file named "start" otherwise if file already exists, it'll overwrite it.
3.$ ls -i copyme copiedme //will give u files inode numbers
648284 copiedme 650704 copyme
4.when we move file, that file's inode number will be the same asas long as the destination file resides on the same filesystem.
5. regular expression (also called a "regex" or "regexp") is a special syntax used to describe text patterns.
6.· /tmp (scans for the literal string /tmp)
· "\[box\]" (scans for the literal string [box])
· "\*funny\*" (scans for the literal string *funny*)
· "ld\.so" (scans for the literal string ld.so)
7. regex, hda[12] will search hda1 or hda2.
8.You can reverse the meaning of the square brackets by putting a ^ immediately after the [.
9.if you put a . inside square brackets, it allows the square brackets to match a literal ., just like the 1 and 2
10.
$ grep dev[.]hda /etc/fstab
Alternately, we could also type:
$ grep "dev\.hda" /etc/fstab
11.in regex
ab*c matches abbbbc but not abqc (if a glob, it would match both strings --)
· ab*c matches abc but not abbqbbc (again, if a glob, it would match both strings)
· ab*c matches ac but not cba (if a glob, ac would not be matched, nor would cba)
· b[cq]*e matches bqe and be (if a glob, it would match bqe but not be)
· b[cq]*e matches bccqqe but not bccc (if a glob, it would match the first but not the
second as well)
· b[cq]*e matches bqqcce but not cqe (if a glob, it would match the first but not the
second as well)
· b[cq]*e matches bbbeee (this would not be the case with a glob)
· .* will match any string. (if a glob, it would match any string starting with .)
· foo.* will match any string that begins with foo (if a glob, it would match any string
starting with the four literal characters foo..)
12. ^ and $ will match begining and ending of lines respectively.
eg., ^# will search for text pattern
13.^ and $ can be combined to match an entire line. For example, the following regex will match
a line that starts with the # character and ends with the . character, with any number of other
characters in between:
$ grep '^#.*\.$' /etc/fstab
# /etc/fstab: static file system information.
In the above example, we surrounded our regular expression with single quotes to prevent $
from being interpreted by the shell.
14.For example, if we wanted to refer to a file called fredsfile.txt in
Fred's home directory, we could type:
$ ./myprog ~fred/fredsfile.txt
15 looking at directories only
ls -dl /usr /usr/bin /usr/X11R6/bin ../share
16.touch copyme
The touch command updates the "mtime" of a file if it exists (recall the sixth column in ls
-l output). If the file doesn't exist, then a new, empty file will be created.
17.A given inode can have any number of hard links, and
the inode will persist on the filesystem until the all the hard links disappear. When the last hard link disappears and no program is holding the file open, Linux will delete the file automatically.
18. linking is two tyepes hard and symbolic links. with symbolic links we can even refer to directories also, where as with hardlinks it is not possible.
19. hardlinks limited to filesystem. it links to inode of a file.where are symbolic links will link using the name(or path). so we can't delete a file that has hardlinks. where as files/directories we can delete even they have symbolic links.
20. if directory structure is /dir1/dir2, then /dir1/dir2/.. will be having the inode as /dir1 //check whether it is a hard link?
21. $ ln -s secondlink thirdlink //symbolic link
$ ls -l firstlink secondlink thirdlink //hard link
-rw-rw-r-- 2 agriffis agriffis 0 Dec 31 19:08 firstlink
-rw-rw-r-- 2 agriffis agriffis 0 Dec 31 19:08 secondlink
lrwxrwxrwx 1 agriffis agriffis 10 Dec 31 19:39 thirdlink -> secondlink
we can say a file is symbolic link by seeing ls-l, first column is "l" and or ->.
22.$ln -s /usr/tmp t //creates a symbolic link
$ cd t //go to the directory which symbolic link is pointing.
23. in bash prompt is #.
24.if we use symbolic links as relative path, that link may broke, whenever we changes that link into another folder.
25.to move both files, /usr/bin/keychain and /usr/bin/kc to /usr/local/bin:
# mv /usr/bin/keychain /usr/bin/kc /usr/local/bin
26.rm -rf is the method of removing a directory tree.
27.wildcard support or "globbing" allows you to specify multiple files at once by using a wildcard pattern.
28.rm file* The * wildcard matches any character or sequence of characters, or even "no character."
29.The operative rule here is that glob patterns are expanded only if they match objects in the filesystem.
30. in globbing
/tmp/my*1 matches all files in /tmp that begin with my and end with 1, including the file my1.
? matches any single character.
[] wildcard is like a ?, but it allows more specificity.
myfile[12] will match myfile1 and myfile2. The wildcard will be expanded as long
as at least one of these files exists in the current directory.
· [Cc]hange[Ll]og will match Changelog, ChangeLog, changeLog, and changelog. As you can see, using bracket wildcards can be useful for matching variations incapitalization.
· ls /etc/[0-9]* will list all files in /etc that begin with a number.
· ls /tmp/[A-Za-z]* will list all files in /tmp that begin with an upper or lower-case letter.
.rm myfile[!9] will remove all files named myfile plus a single character, except for
myfile9.
31.
$ echo [fo]* > /tmp/mynewfile.txt //check
right is
$ echo '[fo]*' > /tmp/mynewfile.txt
or
$ echo \[fo\]\* > /tmp/mynewfile.txt
32.check
Note that double quotes will work similarly to single quotes, but will still allow bash to do some limited expansion. Therefore, single quotes are your best bet when you are truly interested in passing literal text to a command. For more information on wildcard expansion,type man 7 glob. For more information on quoting in bash, type man 8 glob and read the section titled QUOTING.
33.in regex
You can reverse the meaning of the square brackets by putting a ^ immediately after the [.In this case, the brackets will match any character that is not listed inside the brackets.
34.
Again, note that we use [^] with regular expressions, but [!] with globs:
35.from FHS(File system Hierarchy Standard)
· / (the root directory)
· /boot (static files of the boot loader)
· /dev (device files)
· /etc (host-specific system configuration)
· /lib (essential shared libraries and kernel modules)
· /mnt (mount point for mounting a filesystem temporarily)
· /opt (add-on application software packages)
· /sbin (essential system binaries)
· /tmp (temporary files)
· /usr (secondary hierarchy)
· /var (variable data)
36. accroding to FHS, files categories are
shareable: files can shered between hosts.
unshareable: files specific to a given host.
variable: data can be modified.
static: data can't modified.
+---------+-----------------+-------------+
| | shareable | unshareable |
+---------+-----------------+-------------+
|static | /usr | /etc |
| | /opt | /boot |
+---------+-----------------+-------------+
|variable | /var/mail | /var/run |
| | /var/spool/news | /var/lock |
+---------+-----------------+-------------+
37. after setting PATH=$PATH:~/bin: will add urhomedirectory/bin to ur PATH. to be effective use $export PATH
38.which will find out the command location in PATH. which -a lists all locations it present.
39. whereis command gives more information than which.
40.$ find /usr/share/doc -name README //will find.
/usr/share/doc/README
41.find /usr/share/doc -name README\* //will find.
/usr/share/doc/iproute2-2.4.7/README.gz
/usr/share/doc/iproute2-2.4.7/README.iproute2+tc.gz
42. by ignoring case we can write
find /usr/share/doc -name '[Rr][Ee][Aa][Dd][Mm][Ee]*'
OR
find /usr/share/doc -iname readme\* //because -iname option ignores case.
43.using regex in find.
find /etc -iregex '.*xt.*'
/etc/X11/xkb/types/extra
/etc/X11/xkb/semantics/xtest
*)Note that unlike many programs, find requires that the regex specified matches the entire path, not just a part of it. For that reason, specifying the leading and trailing .* is necessary;purely using xt as the regex would not be sufficient.
44.The -type option allows you to find filesystem objects of a certain type. The possible arguments to -type are b (block device), c (character device), d (directory), p (named pipe), f (regular file), l (symbolic link), and s (socket). For example, to search for symbolic links in /usr/bin that contain the string vim:
$ find /usr/bin -name '*vim*' -type l
/usr/bin/rvim
/usr/bin/vimdiff
45.You could search for files that were created in the past 24 hours:
$ find . -name \? -mtime -1
./a
Or you could search for files that were created prior to the current 24-hour period:
$ find . -name \? -mtime +0
--we can addtionally specify -daystart option for searching files from daystart.
46.The -size option allows you to find files based on their size. By default, the argument to -size is 512-byte blocks, but adding a suffix can make things easier. The available suffixes are b (512-byte blocks), c (bytes), k (kilobytes), and w (2-byte words). Additionally, you can prepend a plus sign ("larger than") or minus sign ("smaller than").
$ find /usr/bin -type f -size -50c
47. -exec option. This option accepts a command line to execute as its argument, terminated with ;, and it replaces any occurrences of {} with the filename. example:
$ find /usr/bin -type f -size -50c -exec ls -l '{}' ';'
-rwxr-xr-x 1 root root 27 Oct 28 07:13 /usr/bin/krdb
-rwxr-xr-x 1 root root 35 Nov 28 18:26 /usr/bin/run-nautilus
48.locate command matches against any part of a pathname, faster than find, because uses database generated by updatedb(It will index the entire filesystem.) if locate don't works, then u should run updatedb for database.
49.slocate-secure locate, will check teh current user permissions to directories and gives the output.
50.xeyes -center red//game eyes sees ur mouse.
51. ^c(Ctrl+c) -will kill the process, where as ^z will stop the process(i.e process will be there, but stopped).
52.fg command used for continue the stopped processes.
53.bg command let the process go running in background.
54. we can list processes by jobs command.
$ jobs -l
[1]- 16217 Running xeyes -center red &
[2]+ 16224 Running xeyes -center blue &
The numbers in the left column are the job numbers bash assigned when they were started. Job 2 has a + (plus) to indicate that it's the "current job," which means that typing fg will bring it to the foreground. You could also foreground a specific job by specifying its number; for example, fg 1 would make the red xeyes the foreground task.
55.man SIGNALS
56.$ kill -s SIGSTOP 16224
Linux kills, stops or continues processes when they are sent the SIGINT, SIGSTOP, or SIGCONT signals respectively.
57.By default, kill sends SIGTERM, which is not identical to SIGINT of Control-C fame, but usually has the same results:
$ kill 16217
$ jobs -l
[1]- 16217 Terminated xeyes -center red //SEE THIS
[2]+ 16224 Stopped (signal) xeyes -center blue
58.Processes can ignore both SIGTERM and SIGINT, either by choice or because they are stopped or somehow "stuck." In these cases it may be necessary to use the big hammer, the SIGKILL signal. A process cannot ignore SIGKILL:
$kill -s SIGKILL
59. Some shells(not
bash by default), will deliver a SIGHUP signal to backgrounded jobs when you logout, causing them to quit. To protect processes from this behavior, use the nohup when you start the process:
$ nohup make &
60. ps ax //show all processes running in ur system.
ps //shows all processes owned by u, and that have the controlling terminal
ps x //shows all processes owned by u, and that even without the controlling terminal
ps x --forest //shows all processes in parent-child relationships
pa au //list more information including username,cpu,tty,start,time.
pa al //lists more information including ppid,uid,tty(terminal),time.
61.top displays a continuously updated process listing, along with some useful summary information:
61.nice -n 10 commandname //will start the commandname and put it as allow other processes to run at their normal speed, regardless of how CPU-hungry commandname
//what -n will do? by default all processes start with priority of 0.
62.The nice command can only change the priority of a process when you start it. If you want to change the niceness setting of a running process, use renice:
$renice 10 641 //give pid
641: old priority 0, new priority 10
63.$ ls -s | sort -n //pipe
$ bzip2 -d linux-2.4.16.tar.bz2
$ tar xvf linux-2.4.16.tar
$ bzip2 -dc linux-2.4.16.tar.bz2 | tar xvf - //pipe
$ cat myfile.txt | sort | uniq | wc -l //pipe
uniq removes any duplicate lines (and requires its input tobe sorted)
64. echo prints its arguments to the terminal. Use the -e option if you want to embed backslash escape sequences; for example echo -e "foo\nfoo" will print foo, then a newline, and then foo again. Use the -n option to tell echo to omit the trailing newline that is appended to the output by default.
64.
man blah //check whether it is there or not
65.
tac
tac is like cat, but prints all lines in reverse order; in other words, the last line is printed first.
expand
Convert input tabs to spaces. Use the -t option to specify the tabstop.
unexpand
Convert input spaces to tabs. Use the -t option to specify the tabstop.
66.cut
cut is used to extract character-delimited fields from each line of an input file or stream.
67.nl
The nl command adds a line number to every line of input. Useful for printouts.
pr
pr is used to break files into multiple pages of output; typically used for printing.
tr
tr is a character translation tool; it's used to map certain characters in the input stream to certain other characters in the output stream.
sed
sed is a powerful stream-oriented text editor.
awk
awk is a handy line-oriented text-processing language.
od
od is designed to transform the input stream into a octal or hex "dump" format.
split
split is a command used to split a larger file into many smaller-sized, more manageable chunks.
fmt
fmt will reformat paragraphs so that wrapping is done at the margin. These days it's less
useful since this ability is built into most text editors, but it's still a good one to know.
paste
paste takes two or more files as input, concatenates each sequential line from the input files, and outputs the resulting lines. It can be useful to create tables or columns of text.
join
join is similar to paste, but it uses a field (by default the first) in each input line to match up what should be combined on a single line.
tee
The tee command will print its input both to a file and to the screen. This is useful when you want to create a log of something, but you also want to see it on the screen.
68.$ sort <
apple
cranberry
banana
END
apple
banana
cranberry
In the example above, we typed the words apple, cranberry and banana, followed by
"END" to signify the end of the input. The sort program then returned our words in
alphabetical order.
69."uname -r" to have the uname command print out the release of the Linux kernel that's currently running.
uname -a //gives u lot of info. below
info. option
kernel name
hostname
kernel release
kernel version
machine
processor
hardware platform
operating system -o "GNU/Linux"
70.in /lib/modules u'll find kernel info.
71. lsmod //To see what modules are currently loaded on your system
72.a". The "depmod" program will then scan all the modules in your directories in /lib/modules and freshening the dependency information.It does this by scanning the module files in /lib/modules and looking at what are called "symbols" inside the modules:
# depmod -a
73.Locating kernel modules: For 2.4 kernels, they're typically any file in the /lib/modules tree that ends in ".o". To see all the modules in /lib/modules, type the following:
# find /lib/modules -name '*.o'
74.to load a module into a running kernel use insmod
# insmod /lib/modules/2.4.20-gaming-r1/kernel/fs/fat/fat.o
75.one normally loads modules by using the "modprobe" command. One of the nice things about the "modprobe" command is that it automatically takes care of loading any dependent modules. Also, one doesn't need to specify the path to the module you wish to load, nor does one specify the trailing ".o".
76.Let's unload our "fat.o" module and load it using "modprobe":
# rmmod fat
# lsmod | grep fat
# modprobe fat
# lsmod | grep fat
fat 29272 0 (unused)
77.use the "modinfo" command to learn interesting things about your favorite modules:
# modinfo fat
filename: /lib/modules/2.4.20-gaming-r1/kernel/fs/fat/fat.o
description:
author:
license: "GPL"
Note: /etc/modules.conf file. This file contains configuration information for modprobe. It allows you to tweak the functionality of modprobe by telling it to load modules before/after loading others, run scripts before/after modules load, and more.
78."man modules.conf"
79. all manual pages(man) are stored in /usr/share/man folder, inside this directory man pages are organized in
man1 User programs
man2 System calls
man3 Library functions
man4 Special files
man5 File formats
man6 Games
man7 Miscellaneous
80.we use "whatis" command for checking whether multiple pages are there in man pages. we can access ne one of that using man (entry number) (commnad).
81.man -k command, searches command-string in all man pages, and prints the entries associated with it.
82.apropos command, works same as man -k command, where as makewhatis command builds database for these commands.
83.we use /etc/man.conf file for setting MANPATH
84. in info command gives help to use commands,in this hydpertext is possible, it something more than man.
85. u'll find more help in /usr/share/docs directory. much more than man.
86. http://www.tdlp.org in this site u'll get lot of linux resources.
87.ldconfig program uses is used to maintain the file /ets/ld.so.cache
88. what is the purpose of these?
etc/bashrc
/etc/profile
~/profile
~/bashrc
~/bash_profile
89.* /etc/bashrc and /etc/profile are system-wide (=> initialization for all users).
*/etc/profile, ~/.profile, ~/.bash_profile are read during login.
~/.profile is the old Bourne shell file, ~/.bash_profile is the Bash Shell file.
*/etc/bashrc , ~/.bashrc are Runtime Commands files and are run every time a new shell is started. You place alias and functions in these files.
So, when you log in, the system will first read /etc/profile, then ~/.bash_profile, then ~/~.profile (if it exists).
~/.bashrc wil be sourced in ~/.bash_login and /etc/bashrc is sourced in ~/.bashrc.
90.4/ what is the numeric value of the file permission mode
-rwxr-sr--
the answer is 2754
91.when do you need to run the lilo command choose every correct answer
after every modification of the file lilo configuration file
c/ after installing a new kernel with a new name in /boot
d/ after overwriting the old kernel in /boot with a new one
92.lspci: lists chipset information of all attached PCI components. Lists I/O and IRQ settings with the -v flag . Also notice the -b (BUS centric) option which shows allocations assigned by the BIOS rather than the kernel.
dmesg. This displays the kernel message logged at boot time. The kernel scans all the hardware on the system and can automatically allocate modules (drivers) for given chipsets. These messages are also available in /var/log/dmesg.
93.every file is owned by one user and one group.
94.in ls -l, command first column represents file type, i.e
'd' directory
'l' symbolic link
'c' character special device
'b' block special device
'p' fifo
's' socket
95.
# whoami
root
# su drobbins
$ whoami
drobbins
96.groups command will gives u which groups u belongs to. we can check other users groups also with this command by #groups root prabodh //where root and prabodh are users
97.# chown root /etc/passwd //to change owner of a file.
# chgrp wheel /etc/passwd //to change group of a file.
# chown root.wheel /etc/passwd //to change owner&group of a file.
You may not use chown unless you are the superuser, but chgrp can be used by anyone to
change the group ownership of a file to a group to which they belong.
chown and chgrp have a -R option to recursively apply ownership and group changes to an entire directory tree.
98.
$chmod go-w scriptfile.sh
$ chmod =rx scriptfile.sh
99.simply specify the symbolic character for the particular triplets you'd like to modify before the + or - sign. Use u for the "user" triplet, g for the "group" triplet, and o for the "other/everyone" triplet:
$ chmod go-w scriptfile.sh
or we can use = also
$ chmod u=rx scriptfile.sh
100. in chmod numeric modes r=4,w=2,x=1.
101.whenever a new file is created that file's default permissions are based on the umask command. umask default runs as umask 0022. here the permissions numbers are just opp. to normal permissions numbers. //check
|
|
|
|
|
|