Linux Basic Commands
Command
|
Description
|
1. logname
|
Current user name
|
2. pwd
|
Present working directory
|
3. uname
|
Display kernel name
|
4. uname -n
|
Print network hostname
|
5. uname -r
|
Display kernel version
|
6. uname -v
|
Display kernel release date
|
7. uname -i
|
Print hardware platform
|
8. uname -o
|
Print the operating system
|
9. uname -p
|
Print the processser name
|
10. uname -a
|
Print all information
|
11. date
|
Display system date and time
|
12. clear
|
To clear the screen
|
13. cal
|
Display current month calendar
|
14. cal 2014
|
Display 2014 calendar
|
15. cal 9 1987
|
Displays the September 1987 calendar
|
16. bc
|
Open calculator
|
17. bc -v
|
Version of calculator
|
18. hostname
|
Display server name
|
19. hostname -i
|
Display server IP address
|
20. tty
|
Display terminal name
|
21. who
|
To display how many users connected
to server
|
22. whoami
|
Display current username
|
23. uptime
|
Display how long server is “up
&running”, no. Of users connected &avg load on the server.
|
24. which <command name>
|
Show the full path of command
|
25. whereis <command name>
|
Display the binary, source, and
manual page files for a command
|
26. find
|
Search for files in a directory
hierarchy
|
27. set system date and
time
# date -s “yyyy-mm-dd hh:mm:ss”
28. To view help for a
command (manual pages)
# man <command>
29. Viewing list of
Files & Directories:
Syntax : # ls <options> <file>
Options:
-a --> To check the hidden object
-l --> To list the properties of an object
-s --> To check the size in block
-r --> To check reverse order
-R --> List Sub directories Recursively
-Q --> To see files in double quotes
-m --> List of entries with comma separated
Eg :-
#
ls -a
#
ls -la
#
ls -lr
Working with Files:-
A collection of data is called file. In linux – platform,
CAT, Touch, vi are some at the default commands. To create a file, but there
are some differences between these three commands.
30. Cat (concatenation):
This command is
used to create single file with data and also to check the data of exiting
file, but we cannot modify the data.
Create a file :
# cat > file
-------------
-------------
ctrl+d
(save & quit)
31. Open the file:
# cat < filename
or
# cat filename
32. To append the file:
# cat >> filename
---------------------
--------------------
ctrl+d (save & quit)
33. To open multiple files:
# cat file1 file2 file3
Disadvantages:
Using this command we can't create multiple
files and we can't edit the text at the file.
Touch:
This command is
used to create multiple files, but are empty files and also it use to change
date and time of an existing files and directories.
34. To create multiple files:
# touch f1 f2 f3
Disadvantages:
Using
this command we can't modify the text of the database files.
35. change current Date
and Time:
# touch f1
36. Change Time stamp
of a file or directory
Syntax
# touch <option> <argument> <file/directory>
# touch –t YYYYMMDDHHMM
<file/directory-name>
Deleting the files :
37. “rm” command is
used for remove files
38. # rm <filename>
39. # rm -i
<filename> --> asking confirmation
40.
# rm -f
<filename> --> delete file forcibility.
41.
Remove multiple files at once
# rm <file 1> <file 2>
<file 3>
Working with Directories:
“mkdir” (Make
Directory) command is used for creating Directories.
Syntex: # mkdir
<option> <Directory
name>
42. To create a Directory
# mkdir
<dir name>
43 Creating multiple directories
# mkdir dir1 dir2 dir3
44.
Creating nested tree structure (sub directories inside
directories)
# mkdir -p world/asia/india/ap/hyd/kphb
#
ls -R world
(or)
# tree world
Removing Directories:
#
rmdir <dirname>
# rm -r <dirname>
48. # rm -ri <dirname> --> asking confirmation message
49. # rm -rf <dirname> --> remove forcefully.
Navigation Commands:
50. # cd --> To change a directory
51. #
cd ..
--> To move one level back
52. #
cd ../.. --> To move two levels back
53. #
cd - --> To go to the previous working
directory
54. #
cd <space-bar> --> To go to the users home directory
55. #
cd <dir-name> --> To move to the particular directory.
Copying files and directories :
“cp” command is used to copy file or
directory from one place to another.
56. To copy a file
#
cp file1 file2
57. To copy a file into directory
#
cp file1 dir1
#
cp file1 file2 file3 dir1
#
cp -R <source directory>
<destination dir>
#
cp -R dir1 dir2
Move and Rename – Files and Directories :
“mv” (move) command
is used to move files and directories from one place to another, and also this
command is used to rename the file and directories.
Syntex: # mv
<option> <source> <destination>
60.
To move a file
#
mv file1 dir1
# mv dir1 dir2
#
mv <old name> <new name>
Creating hidden files and directories :
To hide a file start file name with “.” character
63. #
cat > .filename
64. #
mv file1
.file1 (To hide
existing file)
65. #
mv .file1
file1 (To unhide a file)
66. #
mkdir .dir1
(To create hidden directory)
67. #
mv .dir1 dir1 (To unhide a directory)
68. # ls
-l (or ll ) (Display longlist format, i.e, with 9 fields)
(i) File type, where '-' is a file and 'd'
is a directory.
(ii) permissions of file or directory
(iii) Number of links (l)
--> link file
(iv) owner of the file
(v) Group of file
(vi) File size in bytes
(vii) Creation data of file
(viii) Creation time of file
(ix) Name of file
Identify Files &
Directories with colors:
# ls -l
Files - Black
Directories
-
Blue
Links - Skyblue
Zip - Red
No comments:
Post a Comment