[Linux] Summary of Linux Commands

User Management

Recently I have been setting up a CDH cluster of about 10 nodes. The cluster uses 10 CentOS 6.7 servers, so I frequently need to use Linux user management commands.

  1. Change password

    1
    
    passwd
    

    Enter the new password and confirm it. For security, the password should include uppercase and lowercase letters, numbers, and special characters. Linux will also remind you of the password rules.

  2. Switch user

    1
    
    su hdfs
    

    This switches to the hdfs user.
    Alternatively, without switching users, you can execute a command or access a file with a specific user’s permissions:

    1
    
    su hdfs hadoop fs -mkdir /user/hdfs/test
    

    This creates a test directory at /user/hdfs/ on the cluster using hdfs user permissions.

File Management

Create a directory

1
mkdir [folder]

Create a file

1
touch/vi [filename]

Timezone Selection

  1. Follow the prompts to select a timezone, then enter the suggested command.

    1
    
    tzselect
    
  2. Modify the timezone in the clock file.

    1
    2
    
    vi /etc/sysconfig/clock
    ZONE="Asia/Shanghai"
    
  3. Delete the existing localtime and create a new one.

    1
    2
    
    rm /etc/localtime
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    

Run Commands at Startup

Edit the rc.local file

1
vi /etc/rc.local

Start the NTP Service to Sync with a Time Server on the LAN

1
2
service ntpd start
/usr/sbin/ntpdate 192.168.34.115

[To be continued…]

Licensed under CC BY-NC-SA 4.0