Linux CMD
Linux CMD
Linux CMD
Kt Bizmatics 11:10-12:45
o last,
o chage,
o chsh,
o lsof,
o chown,
o chmod,
o useradd,
o userdel,
o newusers etc.
o Read: User can read the file and list the directory.
o Write: User can write new files in the directory .
o Execute: User can access and run the file in a directory.
1. vi filename
2. Q. How do you list all files in a directory, including the hidden files?
3. Q. How do you find out all processes that are currently running?
4. Q. How do you find out the processes that are currently running or a particular
user?
A. less filename
cat filename
pg filename
pr filename
more filename
most useful is command: tail file_name - you can see the end of the log file.
8. Q. What would you use to view contents of a large error log file?
A. Using telnet server_name or ssh -l ( ssh - OpenSSH SSH client (remote login program))
A. man command_name
A. ls -lac
-a all entries
-c by time
12.Q. How do you create a symbolic link to a file (give some reasons of doing so)?
A. ln /../file1 Link_name
Links create pointers to the actual files, without duplicating the contents of
the files. That is, a link is a way of providing another name to the same file.
14.Q. How do you get its usage (a filesystem)?
A. By storing and manipulate files.
15.Q. How do you check the sizes of all users� home directories (one command)?
A. du -s
df
The du command summarizes disk usage by directory. It recurses through all subdirectories and
shows disk usage by each subdirectory with a final total at the end.
Q. in current directory
A. ls -ps (p- directory; s - size)
A. bg %4 (job 4)
18 Q. What utility would you use to replace a string '2001' for '2002' in a text file?
19. Q. What utility would you use to cut off the first column in a text file?
A. awk, kde
commands are stored on the hard disk among the other utility programs.
27. Q. What command do you type to find help about the command who?
A. $ man who
28. Q. What is the difference between home directory and working directory?
A. Home directory is the directory you begin at when you log into the
system. Working directory can be anywhere on the system and it is where you are currently
working.
29. Q. Which directory is closer to the top of the file system tree, parent directory or current
directory?
A. The parent directory is above the current directory, so it is closer to
the root or top of the
file system.
32. Q. What are two subtle differences in using the more and the pg commands?
A. With the more command you display another screenful by pressing
the spacebar, with pg you press the return key.
The more command returns you automatically to the UNIX
shell when completed, while pg waits until you press return.
33. Q. When is it better to use the more command rather than cat command?
A. It is sometimes better to use the more command when you are viewing
a file that will display over one screen.
34. Q. What are two functions the move mv command can carry out?
A. The mv command moves files and can also be used to rename a file or directory.
37. Q. Draw a picture of the final directory structure for the "soccer"
directory, showing all the files and directories.
40. Q. Which of the quoting or escape characters allows the dollar sign ($) to retain its special
meaning?
A. The double quote (") allows the dollar sign ($) to retain its special meaning.
Both the backslash (\) and single quote (') would remove the special meaning of the dollar sign.
47. Q. How can you find a path to the file in the system?
A. locate file_name (locate - list files in databases that match a pattern)
53. Q. If you would like to run two commands in sequence what operators you can use?
59. Q. How to find difference in two configuration files on the same server?
A. Use diff command that is compare files line by line
diff -u /usr/home/my_project1/etc/ABC.conf /usr/home/my_project2/etc/ABC.conf
60. Q. What is the best way to see the end of a logfile.log file?
A. Use tail command - output the last part of files
tail -n file_name ( the last N lines, instead of the last 10 as default)
61. Q. Please write a loop for removing all files in the current directory that contains a word 'log'
A. for i in *log*; do rm $i; done