Linux operating systems (2): on the management server common commands linux mark (for myself)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_41554005/article/details/90181462

Gpu state inquiry

gpustat -cpu

Network Service Restart

sudo systemctl restart networking.service

sudo service network-manager restart

Returns the current position

pwd

Command: id username

To view the user information

When you install ubuntu, create a normal user, not sudo permissions, run sudo related command failed because the average user is not added to the Power Users group,

Use the following command can be added to the user group (may also be a super user group).

Command is as follows:

sudo usermod -aG Super User Group Name User Name

Reiko: sudo usermod -aG sudo username

Wherein a: represents added, G: group name specified

The second method is to directly modify, / etc / sudoers

Sudoes modify files in two forms,

One is to add sudo permissions to individual users. the way is

Additional day this line udoers file: username ALL = (ALL: ALL) ALL

By way of cancellation sudo rights of users, it is to delete diverted.

The second is to add sudo permissions to user groups. the way is

%admin ALL=(ALL:ALL) ALL

To the admin user group all users have sudo privileges.

2, delete the specified user from the user group

sudo usermod -G user user name group name

Liezi: sudo usermod -G 1 -G group 2 group username

Wherein -G represents a: group 1 and group 2 was added, can be added to a plurality of groups, and of course may be one group.

    -G的含义是把用户添加到指定的用户组,但是会自动从其他组中删除。

    -a的含义是追加,但不会从其他组中删除。

Create a new user adduser
https://blog.csdn.net/timothy93bp/article/details/77679000

ps -ef | grep mcfcm_st | grep -v grep | cut -c 9-15 | xargs kill -9

Pipe character "|" designed to separate the two commands, command pipe character to the left of the output will be used as input pipe symbol to the right of command. The following talk coupled together by pipe

Several command:
"PS - EF" is a linux process in view of all the commands. Then the process will be retrieved as input "grep mcfcm_st" the next command.
"Grep mcfcm_st" output result is that all processes containing the keyword "mcfcm_st", which is a common feature remote connection process of the Oracle database.
"Grep -v grep" is the process of removing contain the keyword "grep" in the process listed.
"Cut -c 9-15" is the interception of the first nine character input lines to 15 characters, and this is precisely the process ID PID.
"Xargs kill -9" xargs command is used in the preceding command output (PID) as a "kill -9" command parameter, and executes the command.

"Kill -9" will be forced to kill the specified process, thus successfully cleared all the oracle remote connection process. Other similar tasks, just need to modify the key part "grep mcfcm" in it.

ps -ef | grep mcfcm | grep -v grep | cut -c 9-15 | xargs kill -9

Author: leaves a brother
Source: CSDN
Original: https: //blog.csdn.net/abc5382334/article/details/45311279
Copyright: This article is a blogger original article, reproduced, please attach Bowen link!

2, killall process name

  如杀死java相关进程:killall java

1, ps command and kill with:

   ps -ef|grep LOCAL=NO|grep -v grep|cut -c 9-15|xargs kill -9

Pipe character "|" designed to separate the two commands, command pipe character to the left of the output will be used as input pipe symbol to the right of command. The following talk coupled together by pipe

Several command:

 “ ps - ef”是Red Hat 里查看所有进程的命令。这时检索出的进程将作为下一条命令“grep LOCAL=NO”的输入。 

"Grep LOCAL = NO" output result is that all processes containing the keyword "LOCAL = NO", which is a common feature remote connection process of the Oracle database.

"Grep -v grep" is the process of removing contain the keyword "grep" in the process listed.

"Cut -c 9-15" is the interception of the first nine character input lines to 15 characters, and this is precisely the process ID PID.

"Xargs kill -9" xargs command is used in the preceding command output (PID) as a "kill -9" command parameter, and executes the command.

     “kill -9”会强行杀掉指定进程,这样就成功清除了oracle的所有远程连接进程。其它类似的任务,只需要修改“grep LOCAL=NO”中的关键字部分就可以了

Author: lgh1117
Source: CSDN
Original: https: //blog.csdn.net/lgh1117/article/details/48402285
Copyright: This article is a blogger original article, reproduced, please attach Bowen link!

nohup command can cause permanent command execution continues, and the terminal does not matter, exit the terminal will not affect the operation of the program;
& running in the background is the meaning, but when the user exits the time, command automatically also pulled out.
So, the two combine nohup command & this can make permanent command in the background

File as an example to run_train.sh

source env_set.sh

nohup python -u train_image_classifier.py
–dataset_name=KaTeX parse error: Expected 'EOF', got '\ ' at position 14: DATASET_NAME \̲ ̲ --dataset_dir…DATASET_DIR
–checkpoint_path=KaTeX parse error: Expected 'EOF', got '\ ' at position 17: …HECKPOINT_PATH \̲ ̲ --model_name=…TRAIN_DIR
–learning_rate=0.001
–learning_rate_decay_factor=0.76
–num_epochs_per_decay=50
–moving_average_decay=0.9999
–optimizer=adam
–ignore_missing_vars=True
–batch_size=32 > output.log 2>&1 &
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
. 17
18 is
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
. 11
12 is
13 is
14
15
16
. 17
18 is
TensorFlow run the program, added before or after run_train.sh nohup command file> output.log 2> & 1 & allow the command executed in the background .

Wherein 0,1,2 represent the following meanings:
0 - stdin (Standard INPUT)
. 1 - stdout (Standard Output)
2 - stderr (Standard error)

nohup + & rearmost is to command in the background

output.log is output to the log output.log

2> & 1 is converted into standard output standard error message so that it can output error information to a log output.log come inside.

View Log (dynamic display)

-f output.log tail
1
1
View Log (one-time display the whole file)

output.log CAT
1
1
View current Python process

-ef PS | grep Python
1
1
kill process

sudo kill process number
1
1
the kill process ID # 9 lore

When we work in a terminal or console, you may not want to run a job due and occupy the screen, probably because there are more important things to do, such as reading e-mail. For access to the disk-intensive process, and we hope that it can load non-peak hours (for example in the morning) segment in daily. In order for these processes can run in the background, that is not running on the terminal screen, there are few options available.

1、&

When a job is running in the foreground, the terminal is occupied by the job; after the command may be running in the background & achieved. For example: sh test.sh &

Suitable for a find, time-consuming sorting and some shell script command running in the background. When running in the background job beware: the need for user interaction command is not on the background, so that your machine because there Shadeng. However, the job will run in the background as output the results to the screen, interfere with your work. If on the job running in the background will produce a lot of output, it is best to use the following method to redirect its output to a file:

command> out.file 2> & 1 &
such, all standard output and error will be redirected to the file called out.file.
Note: When you successfully submit process, the process will show a number, you can use it to monitor the process, or kill it. (ps -ef | grep kill -9 process ID or process ID)

2, nohup command:

After using & Order, the job is submitted to run in the background, the current console is not occupied, but the current console but a turn off (while signed out), the job will stop running. nohup command corresponding process can continue to run after you exit the account. nohup is not meant to hang (no hang up). The general form of the command is: nohup command &

If you submit jobs using the nohup command, then all output by default the job are redirected to a file named nohup.out, unless otherwise specified the output file:

nohup command > myout.file 2>&1

[Example]

nohup.sh

. 1 = I
the while [$ I -le 100000]
do
echo the result.txt >> I $
I = expr $i + 1
DONE
. 1) using sh nohup.sh executed, the current command line will hang live as:

2) Use sh nohup.sh & execution, will submit a job to the background, the current release of the command line, and shows the process ID; but if you help the current command window is closed, the entire job is stopped;

Note: You can use ps -ef | grep nohup.sh to see the background job situation.

3) Use nohup sh nohup.sh> log 2> 1 & &, submit jobs to the same background, the release of the current window; and even if the current command window is closed, the job is still running.

Note: Use the nohup execution command does not return the current process, to track background jobs, you can use the jobs command to see; or using ps -ef | grep nohup.sh view

3, ctrl + z
may be a command is being executed in the foreground in the background, and paused.

4、Ctrl+c

Termination reception command.

5, jobs
see how many commands are currently running in the background.
PID jobs -l option to display all tasks, jobs status can be running, stopped, Terminated. But if the task is terminated (kill), shell delete tasks from a known list of the current shell environment process identity.

6, bg
will be a pause command in the background, into continues in the background. If more than one command in the background, you can use bg% jobnumber the selected command recall.
As shown previously running a script, then go back to view the background job situation

7, fg
will command in the background adjusted foreground continue to run. If more than one command in the background, you can use fg% jobnumber (is the command number, not the process ID) selected command recall.


Author: hurry man child
Source: CSDN
Original: https: //blog.csdn.net/liuxiao723846/article/details/47754479
Copyright: This article is a blogger original article, reproduced, please attach Bowen link!

1, run .sh file

It can directly run by ./sh file, but if you want to run in the background, even if you close the current terminal can also run it, and the need nohup command & command.

(1) & command

      功能:加在一个命令的最后,可以把这个命令放在后台执行

(2) nohup command

      功能:不挂断的运行命令

2, view the current command running in the background

There are two commands you can use, jobs and ps, the difference between the current terminal jobs for viewing tasks running in the background, for a terminal to see it. The ps command is used to view the dynamic process of the moment, you can see the other end background processes running.

(1) jobs command

    功能:查看当前终端后台运行的任务

   

   jobs -l选项可显示当前终端所有任务的PID,jobs的状态可以是running,stopped,Terminated。+ 号表示当前任务,- 号表示后一个任务。

(2) ps command

      功能:查看当前的所有进程

      

     ps -aux | grep "test.sh"    #a:显示所有程序  u:以用户为主的格式来显示   x:显示所有程序,不以终端机来区分

3, close the command is currently running in the background

  kill命令:结束进程

 (1)通过jobs命令查看jobnum,然后执行   kill %jobnum

 (2)通过ps命令查看进程号PID,然后执行  kill %PID

   如果是前台进程的话,直接执行 Ctrl+c 就可以终止了

4, switching and control of front and back office processes

 (1)fg命令

   功能:将后台中的命令调至前台继续运行

   如果后台中有多个命令,可以先用jobs查看jobnun,然后用 fg %jobnum 将选中的命令调出。

 (2)Ctrl + z 命令

   功能:将一个正在前台执行的命令放到后台,并且处于暂停状态

 (3)bg命令

   功能:将一个在后台暂停的命令,变成在后台继续执行

   如果后台中有多个命令,可以先用jobs查看jobnum,然后用 bg %jobnum 将选中的命令调出继续执行。

Author: knowledge of the people
Source: CSDN
Original: https: //blog.csdn.net/u013846293/article/details/74003051
Copyright: This article is a blogger original article, reproduced, please attach Bowen link!

mark
https://www.jianshu.com/p/747e0d5021a2

Linux view a user's process
To view only the processes owned by a specific user, use the following command:

top -U [USERNAME]

and replace [USERNAME] with the name of the user.

Introduction
R & D needs to know a Python script directory, this R & D, but fortunately he was not a back-end research and development.
But when we use the ps or top command to view and can not see the absolute path to the Python script.
I vaguely remember the relevant information can be found in the / proc / $ {PID}, but not used for a long time, forgotten,
and now I have to re-learn the next record.

For more information see the process of Linux
Linux when you start a process, the system will be created under / proc PID to a named folder, there will be information about our processes in this folder, which includes a file that is named exe record the absolute path to see through ll or ls -l command.

cwd symbolic link is the process run directory;
the absolute path to exe symbolic link is the execution of the program;
cmdline is the command input program is run line commands;
Environ record the process environment to run-time;
at fd directory is a process to open or use a file symbolic links.

https://blog.csdn.net/longerzone/article/details/8015941
https://blog.csdn.net/gatieme/article/details/52777721
https://www.cnblogs.com/baby123/p/6477429.html
https://blog.csdn.net/liuyanfeier/article/details/62422742

-s mySession new new tmux
tmux The attach -t mySession
pkill -u your username

Modify common root user's password: sudo passwd user_name then twice enter the new password to the user; 2 root view user password: password is not being viewed, even by root, so the average user, if forgotten password , can refer to the previous step, allowing administrators to use root privileges to modify the password, then the new password to the average user; 3 ordinary users to change their passwords:. passwd command can be used directly above, then it will ask you to enter the original password and a new password.

Author: Yu with the military
link: https: //www.jianshu.com/p/a0a7645a2c2e
Source: Jane book
Jane book copyright reserved by the authors, are reproduced in any form, please contact the author to obtain authorization and indicate the source.

Guess you like

Origin blog.csdn.net/qq_41554005/article/details/90181462