1. How to create new user from command line?
We need to use "useradd" command, which is responsible for creating a new user or update default new user information.
$ useradd <<user_name>> |
The new user will be entered into system files (/etc/passwd and /etc/shadow) as needed, the home directory (/home/user_name) will be created and initial files copied depending on the command line options.
By default user account is locked, we need to setup a new password.
$ passwd <<password>> |
2. How to delete the user from command line?
$ userdel <<user_name>> |
3. Commands to know logged in users?
$ w |
4. How to get the user activation details?
$ finger <<user_name>> |
5. Which command is used to know linux O.S version/System identification details?
$ uname -a |
6. How to check the assigned IP address of a server?
$ ifconfig |
7. How to find the server uptime?
$ uptime |
8. How to know the particular command usage?
$ man <<command_name>> |
9. How to get virtual memory statistics like processes, memory and CPU activity?
$ vmstat |
10. Command to get the free and used memory?
$ free –m -- To get the details in MB |
11. How to get the CPU info from command line?
$ lscpu |
12. How to find disk info (used space, free space and mounted space list)?
$ df –h |
13. How do we get the size of a directory on the command line?
$ du –ch <<dir_name>> | grep total |
14. How to create, rename and remove a particular directory?
$ mkdir <<dir_name>> -- To create directory in current location |
15. How do we navigate between directories in terminal?
$ cd .. // To move directory to one level above |
16. How to know the present working directory?
$ pwd |
17. List of commands which we usually perform on files in UNIX?
$ vi <<file_name>> -- To create new file (or) to edit file |
18. How to replace a particular string with new one in a file?
Open the file in vi editor and follow the below command |
19. How to sort the file content alphabetically (or) numerically?
$ sort <<file_name>> |
20. How to print particular column data from a file?
$ awk ‘{print $2,$3;}’ employee.txt -– to print columns 2 and 3 from employee.txt file |
21. How to truncate the file without disrupting the processes?
$ truncate -s 0 <<file_name>> |
22. How to give permissions to a file?
$ chmod 755 <<file_name>> - (set permissions for ugo --> User, Group and Others) |
23. Basic ‘ls’ commands in linux?
$ ls –- to list files and directories in current directory |
24. How to view a large file in Linux?
$ cat <<file_name>> | more |
25. How to move file/directory from one linux box to another?
$ scp <<local_file_path>> <<user_name>>@<<machine_name>>:<<remote_file_path>> -- To move file from one linux machine to other
$ scp –r <<local_directory_path>> <<user_name>>@<<machine_name>>:<<remote_directory_path>> -- To move directory from one linux machine to other
|
26. How to use tar command to compress and decompress a directory?
$ tar cvf archive_name.tar dirname/ -- To create an uncompressed tar archive |
27. How to get list of running processes?
$ ps –f -- Lists running processes |
28. How to do you stop the running processes?
First you should get the PID by running above command i.e. $ ps –ef | grep “<<App_Name>>” and then run below commands
|
29. How to get Foreground and background processes?
$ jobs -- Lists the background processes with job ID |
30. How to check if a particular process is listening on a particular port on remote host?
$ telnet <<host_name>> <<port>> |
31. How to check the status of a machine in the same network?
$ ping <<host_name>> (or) <<ip_address>> |
32. How to get the IP address of a domain (or vice versa)?
$ nslookup <<domain_name>> |
33. How to know the port availability in linux machine?
$ lsof –i :<<port>> |
34. How to clear the swap memory?
$ sudo swapoff –a |
35. How do we create a soft link/symbolic link in Linux?
$ ln –s <<target_filename>> <<symbolic_filename>> |
36. How to search single/multiple files for some string value?
$ find . –name “<<file_name>>” –exec grep –i “<<searh_string>>” ‘{}’ \; -print -- To search in single file |
Commands which are provided above all are of our knowledge, Please let us know if you find any change in command and also update us for any new commands and same will be shared here with external world. Have A Nice Day !!! Thank You !!!
No comments:
Post a Comment