Tuesday, 15 December 2015

Linux Basic Useful Commands

[root@tricknomedia ~]#
1. ls -l for listing the files as well as directories those are kept in the particular working directory
[root@tricknomedia ~]# ls –l

2. ls -la same as ‘ls -l’ but by this command we can also see the hidden files
[root@tricknomedia ~]#ls –la

3. ls -li same as ‘ls -la’ but it will also shows us the inode number of each and every file
[root@tricknomedia ~]#ls –li

4. ls by this command we can see only file name nothing else
[root@tricknomedia ~]#ls

5. clear it will clear the screen ( short cut ctl + l )
[root@tricknomedia ~]#clear

6. exit to end a current session as well current terminal logging
[root@tricknomedia ~]#exit

7. touch to create a new empty file
[root@tricknomedia ~]#touch myfile.txt

8. cd to change the working/present directory
[root@tricknomedia ~]#cd /home/sachin

9. cat to view the contents of a file and it is also used for creating a new file with some contents
[root@tricknomedia ~]#cat <file name> to view file contents
[root@tricknomedia ~]#cat > newfilename enter, then you can write something in the file and then to save the file contents press clt+d then enter

10. mkdir to make a new directory
[root@tricknomedia ~]#mkdir newdirname
you can also create a directory at your desired path without changing your present working directory
[root@tricknomedia ~]#mkdir /home/sachin/newdirname

11. rm to remove a empty file
[root@tricknomedia ~]#rm filename

12. rmdir to remove a empty directory
[root@tricknomedia ~]#rmdir directoryname

13. rm [-i/-r/-f] to remove a directory with its subdirectories as well as its
files that is to remove a directory which already contains some files in it
[root@tricknomedia ~]#rm -i directory/filename
-i stands for interactively
-r stands for recursively
-f stands for forcefully

14. cp to copy something in a destination file or directory
[root@tricknomedia ~]#cp sourcepath destinationpath
[root@tricknomedia ~]#cp /home/sachin/webmin.rpm /root/abcd
in this example the webmin.rpm file will be copied in
/root/abcd directory

15. mv to move one file or directory from one place to another place, it is also used for renaming adirectory or file
[root@tricknomedia ~]#mv source destination
[root@tricknomedia ~]#mv oldfilename newfilename [to change the file name]

16. man to view the mannual page of commands for syntax
[root@tricknomedia ~]#man commandname

17. info to view the information about any command
[root@tricknomedia ~]#mkdir info

18. –help to view the help doccuments of a command
[root@tricknomedia ~]#commandname –help

19. dir to view the subdirectories and filesn under the directory
[root@tricknomedia ~]#dir

20. who by this command you can see the user name and their ip addresses who have loged in on your server
[root@tricknomedia ~]#who

21. whoami this command shows your current logged in terminal user name
[root@tricknomedia ~]#whoami

22. who am i this command shows you the logged in terminal number and user name and more detailed information
[root@tricknomedia ~]#who am i

23. pwd to view the present working directory
[root@tricknomedia ~]#pwd

24. rpm -ivh to intall a rpm package
[root@tricknomedia ~]#rpm -ivh packagename.rpm
rpm stands for ‘redhat package manager’
-i stands for install
-v stands for verbose mode
-h stands for with hash sign(#)

25. rpm -q to querry about any rpm package
[root@tricknomedia ~]#rpm -q packagename

26. rpm -e to uninstall a rpm package
[root@tricknomedia ~]#rpm -e package

27. find / -name to find any file or directory in linux file system
[root@tricknomedia ~]#find / -name filename

28. su username to switch from one user to another users home directory
[root@tricknomedia ~]#su sachin

29. su – username to switch from one user to another user users home directory directly
[root@tricknomedia ~]#su – sachin

30. useradd to create a new user
[root@tricknomedia ~]#useradd username

31. passwd to give a password of a user
[root@tricknomedia ~]#passwd sachin
give a password for user sachin:(here you have to type a password for sachin user) Confirm password:(again type the same password)

32. userdel to remove a user from linux
[root@tricknomedia ~]#userdel sachin

33. groupadd to add a new group
[root@tricknomedia ~]#groupadd groupname

34. gruopdel to delete a group
[root@tricknomedia ~]#groupdel groupname

35. chown to change the ownership of a file or directory
[root@tricknomedia ~]#chown ownername filename

36. chgrp to change the group ownership of a file or directory
[root@tricknomedia ~]#chgrp newgroupownername filename

37. usermod to modify the user profile
[root@ tricknomedia ~]#usermod -parameter groupname username

0 comments :