Professional Documents
Culture Documents
40 Basic Cmds
40 Basic Cmds
Everything in Linux is a file including the hardware and even the directorie
s.
2. # : Denotes the super(root) user
3. $ : Denotes the normal user
4. /root: Denotes the super user s directory
/home: Denotes the normal user s directory.
5. Switching between Terminals
Ctrl + Alt + F1-F6: Console login
Ctrl + Alt + F7: GUI login
6. The Magic Tab: Instead of typing the whole filename if the unique pattern fo
r a particular file is given then the remaining characters need not be typed and
can be obtained automatically using the Tab button.
7.
c (clear).
17.
ls -lR : To view a long list of all the files (which includes directories) and t
heir subdirectories recursively .
ls *.* : To view a list of all the files with extensions only.
18.
n in Linux.
20. Copying hidden files: cp .* (copies hidden files only to a new destination)
21. dpkg -l : To get a list of all the installed packages.
23. Use of
>
and
>>
: The
>
symbol ( input redirector sign) can be used to add c
ontent to a file when used with the cat command. Whereas >>
can be used to appen
d to a file. If the >> symbol is not used and content is added to a file using o
nly the > symbol the previous content of the file is deleted and replaced with the
new content.
e.g: $ touch text (creates an empty file)
$ cat >text
This is text s text. ( Save the changes to the file using Ctrl +D)
$cat >> text
This is a new text. (Ctrl + D)
24. cat: The cat command can be used to trickly in the following way:
- To count no. of lines from a file : cat <filename> |wc -l
- To count no. of words from a file : cat <filename> |wc -w
- To count no. of characters from a file : cat <filename> |wc
25. To search a term that returns a pattern: cat <filename> |grep [pattern]
26. The tr
tr a-z
A-Z <text >text1 : The command for example is used to translate all the chara
cters from lower case to upper case of the text file and save the changes to a new
file text1'.
27. File permission using chmod: chmod can be used directly to change the file pe
rmission of files in a simple way by giving the permission for root, user and ot
hers in a numeric form where the numeric value are as follows:
r(read-only)=>4
w(write)=>2
x(executable)=>1
e.g. chmod 754 text will change the ownership of owner to read, write and execut
able, that of group to read and executable and that of others to read only of th
e text file.
28. more: It is a filter for paging through text one screenful at a time.
Use it with any of the commands after the pipe symbol to increase readability.
e.g. ls -ll |more
29. cron : Daemon to execute scheduled commands. Cron enables users to schedule
jobs (commands or shell scripts) to run periodically at certain times or dates.
1 * * * * echo
.
| .
| | .
hi
- minute (0
- hour (0
59)
23)
- day of month (1
| | | . - month (1
| | | | .
31)
12) OR jan,feb,mar,apr
day of week (0
7) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
* * * * * command to be executed
Source of example: Wikipedia
30. fsck: Used for file system checking. On a non-journaling file system the fs
ck command can take a very long time to complete. Using it with the option -c di
splays a progress bar which doesn t increase the speed but lets you know how long
you still have to wait for the process to complete.
e.g. fsck -C
31. To find the path of the command: which command
e.g. which clear
32. Setting up alias: Enables a replacement of a word with another string. It is
mainly used for abbreviating a system command, or for adding default arguments
to a regularly used command
e.g. alias cls= clear
33. The du (disk usage) command can be used with the option -h to print the spa
ce occupied in human readable form. More specifically it can be used with the su
mmation option (-s).
e.g. du -sh /home summarizes the total disk usage by the home directory in human
readable form.
34. Two or more commands can be combined with the && operator. However the succ