Big Data -linux commonly used commands

linux common commands

1.1 daily operations command 

View current working directory

pwd

 

View the current system time

date

 

See who's online (who logged on to the server)

who view the current online

last View recent history of landing

 

1.2 file system operations

View Files

ls / View child nodes (folders and files) in the root directory information

ls -al -a show hidden files -l is in a more detailed form display

ll displayed in a list

ll -a show hidden files

 

Change directory

cd  /home

 

Create a folder

mkdir aaa This is a relative path of the wording

mkdir -p aaa / bbb / ccc create a batch file path

mkdir / data which is written the absolute path

 

Delete the folder

You can delete empty directories rmdir

Delete all all child nodes rm -r aaa aaa can put the whole folder and the

rm -rf aaa aaa forced to delete

 

Edit folder name

mv aaa aa1

 

Create a file

touch fbb.txt create an empty file

echo "hello fbb"> fbb.txt and redirection ">" function, the output of an instruction to write to a file, overwrites the original contents of the file

echo "hello, liu yi fei" >> lyf.txt outputs an instruction result is appended to a file, do not overwrite the original file content

 

Operation 1.3 file permissions

Interpretation description format linux file permissions

drwxr-xr-x (may also be represented by a binary 111101101--> 755)

 

d: identifies the node type (d: Folder -: L File: Link)

r: read w: write x: Executable

The first group rwx: represents the owner of the file to its permissions: read-write executables

The second group rx: Specifies the file it belongs to the group of permissions: read, can not write, execute

Third group rx: Specifies the file to other users (with respect to the above two types of users) to its authority: read, and write, execute

 

Modify file permissions

chmod g-rw fbb.txt said it would fbb.txt rw privilege belongs to the group canceled

chmod o-rw fbb.txt said it would cancel its fbb.txt rw rights of others

chmod u + x fbb.txt said it would fbb.txt permission to increase their user x

 

It can also be used to digitally modify permissions

chmod 664 fbb.txt  

Will be modified to rw-rw-r-: as = 664 110 110 100

 

If you want all the contents of a folder permissions unity modified, you can -R parameter

chmod -R 770 aaa/

 

chown the owner of the specified file to the specified user or group, the user may be a user name or a user ID; group may be a group name or group ID

chown Username: group name

chown fbb: fbb aaa / <only root can execute>

 

note:

When the directory does not have execute permissions ordinary users can not enter

Only the file read and write permissions, as long as the parent directory has execute permissions and modify, ordinary users can be deleted. (Delete files instead of modifying it, is the operating parent directory),

 

1.4 basic user management

Add user

useradd  fbb

 

To modify the password to log in

passwd fbb prompted to enter a password to

 

Configuring sudo permissions for users

Edited by root vi / etc / sudoers

In the following location of the file, you can add a line to fbb

root    ALL=(ALL)       ALL    

fbb     ALL=(ALL)       ALL

 

Then, fbb sudo user can use to perform system-level instructions

[fbb@min1~]$ sudo useradd hadoop

 

1.5 System Management Operation

View hostname

hostname

 

Modify the host name (after the restart invalid)

hostname min1fbb

 

Modify the host name (after the restart permanent)

vi /etc/sysconfig/network

 

Modify IP (after the restart invalid)

ifconfig eth0 192.168.33.161

 

Modify IP (after the restart permanent)

vi /etc/sysconfig/network-scripts/ifcfg-eth0

 

The external storage device mount to mount the file system

mkdir / mnt / cdrom to create a directory to mount

mount -t iso9660 -o ro / dev / cdrom / mnt / cdrom / device / dev / cdrom mounted to the mount point: / mnt / cdrom in

 

umount

umount /mnt/cdrom

 

Statistics size of a file or folder

du -sh  /mnt/cdrom/Packages

df -h View disk space

 

Shutdown

halt

 

Restart

reboot

1.6 Configure the DNS server

Modify the mapping relationship ip address and host name

vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.33.61 min1

192.168.33.62 min2

192.168.33.63 min3

 

 

Free secret ssh landing between 1.7 Host Configuration

If you want to log in min1 min2

 

On min1 operation:

First, generate a key pair

ssh-keygen (when prompted, you can directly enter)

 

Then min1 own public key and a copy of the authorization list appended to the file authorized_keys min2 in

ssh-copy-id   min2

 

Verify the effect of:

ssh min2

[root@min1 ~]# ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

96:b9:d1:66:55:78:cb:36:5e:dd:b2:0e:34:48:7e:00 root@min1

The key's randomart image is:

+ - [RS 2048] ---- +

|        E.   ..  |

| the ... |

| o oo .o |

| + The + * +. |

|        S +o + = |

| . =. the |

| . the |

|              .  |

|                 |

+-----------------+

[root@min1 ~]#

[root@min1 ~]# ssh-copy-id min2

root@ min2's password: 【hadoop】

Now try logging into the machine, with "ssh 'min2'", and check in:

 

  .ssh/authorized_keys

 

to make sure we haven't added extra keys that you weren't expecting.

 

[root@min1 ~]# ssh min2

 

Last login: Wed Jan  9 06:37:44 2019 from 192.168.33.2

[root@min2 ~]#

[root@min2 ~]#

 

1.8 minimal installation problems occurring in the system - missing command

Various commands will be missing, missing the various dependencies when installing software

scp命令没有,可以通过安装获得:yum install -y openssh-clients

集群中每台机器上都要安装才行

Guess you like

Origin www.cnblogs.com/qq18361642/p/11856552.html