linux bg and fg commands
Under linux, if we want a task or program to be executed in the background, we can use &. In fact, linux also provides commands for other task scheduling.
- bg: change a command suspended in the background to continue execution; [background background background]
- fg: transfer the command in the background to the foreground and continue to run, [foreground: foreground, important position]
- jobs: check how many commands are currently running in the background
- ctrl + z: you can put a command being executed in the foreground into the background and pause it
- nohup command: run the command without hanging up. nohup means no hang up.
nohup Command [ Arg ... ] [ & ]
Description: the nohup Command runs the Command specified by the Command parameter and any related Arg parameter, ignoring all hangup signals. After logging off, use the nohup Command to run the program in the background. To run the nohup Command in the background, add & (the symbol for "and") to the end of the Command
Let's take a look at the actual operation example and start a clock program:
After ctrl+z, the output is:
This uses pidof xclock to check whether the process number still exists, indicating that the program is suspended in the background
Execute BG% 1 to see the program continue
A more obvious example shows the difference between bg and fg: Firefox & the difference between symbols
If you are running a process and you think it will not end when you exit the account, you can use the nohup command. This command can continue to run the corresponding process after you exit your account. The general form of this command is:
nohup conmmand &
If you submit a job using the nohup command, by default, all the output of the job is redirected to a named nohup Out, unless otherwise specified:
nohup command > myout.file 2>&1
In the above example, the output is redirected to myout File
Full name of linux command
For people who use Linux system, common commands, such as cd/ls/ll /, will be knocked out, but this is only an abbreviation. I think understanding the full name of these instructions is more helpful for us to understand and remember these instructions.
pwd:print work directory Print the current directory and display the absolute path of the current working directory ps: process status(Process status, similar to windows Task manager for) Common parameters:－auxf ps -auxf Show process status df: disk free Its function is to display the number of available disk space and space node information. In other words, report how much free space is left in any installed device or directory. du: Disk usage rpm: Namely RedHat Package Management，yes RedHat One of the inventions of rmdir: Remove Directory(Delete directory) rm: Remove(Delete directory or file) cat: concatenate chain cat file1 file2>>file3 Combine the contents of document 1 and document 2 into file3 in insmod: install module,Load module ln -s : link -soft Creating a soft link is equivalent to creating a shortcut mkdir: Make Directory(Create directory) touch Create a file man: Manual su: Swith user(Switch users) cd: Change directory ls: List files ps: Process Status rmdir: Remove directory mkfs: Make file system fsck: File system check uname: Unix name lsmod: List modules mv: Move file Duplicate name file rm: Remove file Delete file cp: Copy file Copy, of course, can be followed by some parameters. See the specific use of this command ln: Link files fg: Foreground bg: Background chown: Change owner chgrp: Change group chmod: Change mode umount: Unmount tar: Tape archive (Tape Archive) ldd: List dynamic dependencies .a(Extension a): Archive，static library .so(Extension so): Shared object，dynamically linked library .o(Extension o): Object file，complied result of C/C++ source file dpkg: Debian package manager apt: Advanced package tool(Debian Or based on Debian Some are available in the release of Linux Command abbreviation) bin = Binaries (Binary file) apache = "a patchy" server apt = Advanced Packaging Tool ar = archiver as = assembler awk = "Aho Weiberger and Kernighan"The first letter of the last name of the three authors bash = Bourne Again SHell chsh = Change Shell cmp = compare cobra = Common Object Request BrokerArchitecture comm = common cpio = CoPy In and Out cpp = C Pre Processor ed = editor egrep = Extended GREP elf = Extensible Linking Format elm = ELectronic Mail emacs = Editor MACroS eval = EVALuate fd = file descriptors fg = ForeGround fgrep = Fixed GREP fmt = format fsck = File System ChecK fstab = FileSystem TABle fvwm = F*** Virtual Window Manager gawk = GNU AWK gpg = GNU Privacy Guard groff = GNU troff hal = Hardware Abstraction Layer joe = Joe's Own Editor ksh = Korn SHell lame = Lame Ain't an MP3 Encoder lex = LEXical analyser lisp = LISt Processing = Lots of IrritatingSuperfluous Parentheses ls = list lsof = LiSt Open Files