Search This Blog

Pages

Some commonly used Linux commands


1.       To find OS-Version
         cat /etc/redhat-release

2.       To Find the System Configuration
         Lscpu

3.       To check disk space
         df [-h|-i|-H] [<directory>]

4.       To check installed shell
 cat /etc/shells

5.       To run a script file in debug mode to see all running commands in console
 bash –x <script file name>

6.       To list all users
 cut -d: -f1 /etc/passwd

7.       To add user
 useradd <useranme>

  When we add a new user in Linux with useradd command it gets created in locked state and to unlock that user       account, we need to set a password for that account with passwd command.

 passwd <username>

8.       To view user details
 chage -l <username>

9.       To view all users, group files
         vi /etc/passwd
    vi /etc/group
    getent group
    getent passwd

10.    To remove a user account including home directory
 userdel -r <username>

  Note: In case unable to delete a user using userdel will give error that “user <username> is currently used by process   <pid>” then execute below commands and try userdel again:
  su – <username>
 kill -9 -1
 exit

11.    To change owner user/group of a directory
 chown -R <username>:<group> /<directory>

12.    To list/qurey all libraries in Linux
 rpm -qa
 rpm -qa |grep <package_name>*

13.    To extract .tar.gz files
tar -zxvf <compressed file with path> -C <target path>

14.    To check running application on particular port
cat /etc/services | grep 5000

15.    To Find any file
find / -name {file_name}

16.    To uninstall packages using GUI
gpk-application

17.    Permanent configuration of java path in Linux
        Configure PATH environment variable in ~/.bash_profile file for permanent configuration of java as following:


Linux - Points to Remember:

1.       Avoid using the underscore (_) character in machine names. Internet standards dictate that domain names conform to the host name requirements described in Internet Official Protocol Standards RFC 952 and RFC 1123. Domain names must contain only letters (upper or lower case) and digits. Domain names can also contain dash characters ( - ) as long as the dashes are not on the ends of the name. Underscore characters ( _ ) are not supported in the host name.
2.       Linux File Permissions:
Read = 4
Write = 2
Execute = 1



    Note: If a user wants to delete file/folder having all rights then user should also have all rights in its parent folder.

No comments:

Post a Comment