- 20 Advanced Commands for Linux Experts
- 41. Command: ifconfig
- 42. Command: netstat
- 43. Command: nslookup
- 44. Command: dig
- 45. Command: uptime
- 46. Command: wall
- 47. command: mesg
- 48. Command: write
- 49. Command: talk
- 50. Command: w
- 51. Command: rename
- 52. Command: top
- 53. Command: mkfs.ext4
- 54. Command: vi/emacs/nano
- 55. Command: rsync
- 56. Command: free
- 57. Command: mysqldump
- 58. Command: mkpasswd
- 59. Command: paste
- 60.Command: lsof
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Advanced programing in linux
- View the limit of the maximum number of open files (ulimit -a)
- View the maximum number of files allowed in the current system cat /proc/sys/fs/file-max
- File descriptor
- Error header file errno value
- Intelligent Recommendation
- Linux programming-Linux environment
- Linux advanced programming semaphore
- Linux advanced programming experiment
- Linux advanced programming
- Linux Advanced Programming Process
- More Recommendation
- Advanced programming of Linux signal
- Advanced Python Advanced and Linux Advanced Programming
- «Embedded Linux» Linux Advanced Programming
- Introduction to the advanced programming of the UNIX environment
- 4.22 Advanced Programming in the UNIX Environment
- Advanced programing in linux
- Chapter 6 Document IO
- ● Open function
- ● CERAT function
- ● WRITE function
- ● Read function
- ● SLEEK function
- ● Close function
- Chapter VII
- ● VFORK () function
- Chapter 8 Inter-Process Communication
- No nameless pipe:
20 Advanced Commands for Linux Experts
Thanks for all the likes, good words and support you gave us in the first two part of this article. In the first article we discussed commands for those users who have just switched to Linux and needed the necessary knowledge to start with.
In the second article we discussed the commands which a middle level user requires to manage his own system.
What Next? In this article I will be explaining those commands required for administrating the Linux Server.
Linux Expert Commands
41. Command: ifconfig
ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed.
Check Active Network Interfaces
Check All Network Interfaces
Display details of All interfaces including disabled interfaces using “-a” argument.
Disable an Interface
Enable an Interface
Assign IP Address to an Interface
Assign “192.168.1.12” as the IP address for the interface eth0.
Change Subnet Mask of Interface eth0
Change Broadcast Address of Interface eth0
Assign IP Address, Netmask and Broadcast to Interface eth0
Note: If using a wireless network you need to use command “iwconfig“. For more “ifconfig” command examples and usage, read 15 Useful “ifconfig” Commands.
42. Command: netstat
netstat command displays various network related information such as network connections, routing tables, interface statistics, masquerade connections, multicast memberships etc.
List All Network Ports
List All TCP Ports
Show Statistics for All Ports
OK! For some reason if you want not to resolve host, port and user name as a output of netstat.
Fine, you may need to get the output of netstat continuously till interrupt instruction is passed (ctrl+c).
For more “netstat” command examples and usage, see the article 20 Netstat Command Examples.
43. Command: nslookup
A network utility program used to obtain information about Internet servers. As its name suggests, the utility finds name server information for domains by querying DNS.
Query Mail Exchanger Record
Query Name Server
Query DNS Record
Query Start of Authority
Query Port Number
Change the port number using which you want to connect
44. Command: dig
dig is a tool for querying DNS nameservers for information about host addresses, mail exchanges, nameservers, and related information. This tool can be used from any Linux (Unix) or Macintosh OS X operating system. The most typical use of dig is to simply query a single host.
Turn Off Comment Lines
Turn Off Authority Section
Turn Off Additional Section
Turn Off Stats Section
Turn Off Answer Section
Disable All Section at Once
45. Command: uptime
You have just connected to your Linux Server Machine and founds Something unusual or malicious, what you will do? Guessing…. NO, definitely not you could run uptime to verify what happened actually when the server was unattended.
46. Command: wall
one of the most important command for administrator, wall sends a message to everybody logged in with their mesg permission set to “yes“. The message can be given as an argument to wall, or it can be sent to wall’s standard input.
47. command: mesg
Lets you control if people can use the “write” command, to send text to you over the screen.
48. Command: write
Let you send text directly to the screen of another Linux machine if ‘mesg’ is ‘y’.
49. Command: talk
An enhancement to write command, talk command lets you talk to the logged in users.
Note: If talk command is not installed, you can always apt or yum the required packages.
50. Command: w
what command ‘w’ seems you funny? But actually it is not. t’s a command, even if it’s just one letter long! The command “w” is a combination of uptime and who commands given one immediately after the other, in that order.
51. Command: rename
As the name suggests, this command rename files. rename will rename the specified files by replacing the first occurrence from the file name.
Just type the command.
52. Command: top
Displays the processes of CPU. This command refresh automatically, by default and continues to show CPU processes unless interrupt-instruction is given.
53. Command: mkfs.ext4
This command create a new ext4 file system on the specified device, if wrong device is followed after this command, the whole block will be wiped and formatted, hence it is suggested not to run this command unless and until you understand what you are doing.
54. Command: vi/emacs/nano
vi (visual), emacs, nano are some of the most commonly used editors in Linux. They are used oftenly to edit text, configuration,… files. A quick guide to work around vi and nano is, emacs is a.
vi-editor
[press ‘i’ to enter insert mode, or you won’t be able to type-in anything]
- alt+x (exit insert mode, remember to keep some space between the last letter.
- ctrl+x command or your last word will be deleted).
- :wq! (saves the file, with the current text, remember ‘!’ is to override).
nano editor
ctrl +x (to close the editor). It will show output as:
Click ‘y’ to yes and enter file name, and you are done.
55. Command: rsync
Rsync copies files and has a -P switch for a progress bar. So if you have rsync installed, you could use a simple alias.
Now try to copy a large file in terminal and see the output with remaining items, similar to a progress bar.
Moreover, Keeping and Maintaining backup is one of the most important and boring work a system administrator, needs to perform. Rsync is a very nice tool (there exists, several other) to create and maintain backup, in terminal.
Note: -z for compression, -v for verbose and -r for recursive.
56. Command: free
Keeping track of memory and resources is as much important, as any other task performed by an administrator, and ‘free‘ command comes to rescue here.
Current Usage Status of Memory
Tuned Output in KB, or MB, or GB
Check Current Usage in Human Readable Format
Check Status Contineously After Regular Interval
57. Command: mysqldump
Ok till now you would have understood what this command actually stands for, from the name of this command.mysqldump commands dumps (backups) all or a particular database data into a given a file.For example,
Note: mysqldump requires mysql to be running and correct password for authorisation. We have covered some useful “mysqldump” commands at Database Backup with mysqldump Command
58. Command: mkpasswd
Make a hard-to-guess, random password of the length as specified.
Note: -l 10 generates a random password of 10 characters while -l 20 generates a password of character 20, it could be set to anything to get desired result. This command is very useful and implemented in scripting language oftenly to generate random passwords. You might need to yum or apt the ‘expect’ package to use this command.
59. Command: paste
Merge two or more text files on lines using. Example. If the content of file1 was:
60.Command: lsof
lsof stands for “list open files” and displays all the files that your system has currently opened. It’s very useful to figure out which processes uses a certain file, or to display all the files for a single process. Some useful 10 lsof Command examples, you might be interested in reading.
This is not the end, a System Administrator does a lot of stuff, to provide you such a nice interface, upon which you work. System Administration is actually an art of learning and implementing in a very much perfect way. We will try to get you with all other necessary stuff which a linux professional must learn, linux in its basic actually itself, is a process of learning and learning. Your good words are always sought, which encourages us to put in more effort to give you a knowledgeable article. “Like and share Us, to help Us Spread”.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
Advanced programing in linux
Advanced programming in Linux environment
Ssize_t signed type, (typedef definition)
View the limit of the maximum number of open files (ulimit -a)
View the maximum number of files allowed in the current system cat /proc/sys/fs/file-max
File descriptor
Error header file errno value
When the error is reported, the error code is written to errno, strerror(errno) can get the wrong explanation, and perror() can also get the wrong explanation.
Intelligent Recommendation
Linux programming-Linux environment
4.1 Program parameters When a Linux program written in C language runs, it starts from the main function, and the declaration of the main function is as follows: Among them, argc is the number of prog.
Linux advanced programming semaphore
forward from:Understanding and discussing Linux semaphores (don’t talk about it, if you look at it patiently, you will suddenly realize it
) The layout is slightly rough, it is recommended to check th.
Linux advanced programming experiment
This article is reprinted Document management (1) Write code to complete the following functions: 1. Create file file1 and write the string «abcdefghijklmn»; 2. Create file file2 and write t.
Linux advanced programming
This book is a masterpiece in the field of Linux programming. It explains a large number of key knowledge points that programmers need to master, including basic tools in Linux development, Linux syst.
Linux Advanced Programming Process
3, process description The process is the operation of the process entity, which is a separate unit of the system for _ resource allocation _ and _ scheduling _. In order to enable each program (inc.
More Recommendation
Advanced programming of Linux signal
The advanced processing of the signal can carry information. ** First, send the signal terminal ** 1. The first parameter is: signal name 2. The second parameter is: the following structure VOID (* sa.
Advanced Python Advanced and Linux Advanced Programming
Advanced Python Advanced and Linux Advanced Programming 1.linux command This part of knowledge requires multiple taps. Remember the common commands, encounter a Baidu lookup that will not be. Don’t di.
«Embedded Linux» Linux Advanced Programming
Article catalog Written in front Chapter 6 Document IO ● Open function ● CERAT function ● WRITE function ● Read function ● SLEEK function ● Close function Chapter VII ● VFORK () function Chapter 8 Int.
Introduction to the advanced programming of the UNIX environment
Foreword It’s hard to force undergraduates to take exams, and the exams are still very difficult. Here I sort out the exam outline This is also a summary of the first half of the «Advanced .
4.22 Advanced Programming in the UNIX Environment
Multi-process sharing resources, atomic actions IO read write without buffer Shell convention: File descriptor 0 standard input File descriptor 1 standard output File descriptor 2 standard error outpu.
Источник
Advanced programing in linux
Since Linux is an open test, this part of the content is notified.
Chapter 6 Document IO
File I / O Functions — Open files, read files, write files, and more. Most UNIX file I / O simply use 5 functions: Open, Read, Write, Lseek, and Close.
● Open function
#include
#include
#include
int open(const char * pathname, int oflag,…
/*, mode_t mode * / ) ;
Parameter introduction:
1PathName is the name of the file to open or created.
2OFLAG parameters can be used to illustrate multiple selection items of this function. Make or operate with one or more constants (these constants are defined in the header file):
● O_RDONLY is read-only open.
● O_Wronly is only written.
● O_RDWR read, write open.
● You should only specify one in these three constants. The following constants are optional:
● O_Append is added to the end of the file at a time.
● O_CREAT Creates it if this file does not exist.
● Return value:
● Open a descriptor that successfully returns the corresponding file;
● Failure returns 1.
● CERAT function
int creat(const char *pathname,mode_t mode);
Create a file with PathName as a file name, return to the new file handle FD, error returns -1 and error code errno.
● WRITE function
size_t write(int fd,void *buf, size_t count);
Parameter introduction:
Write first parameter fd is a file descriptor to write files;
The first address of the second parameter buf is written;
The third Count is the number of bytes to write data this time.
return value:
After the call is successful, return to the actual write data byte.
● Read function
size_t read(int fd,void *buf, size_t count);
Parameter introduction:
● 1FD is the file descriptor to read the file;
● 2buf is the first address of the read content storage.
● 3Count is the maximum number of bytes to the buffer.
● Return value:
● After the call is successful, return to the actual write data byte number.
● SLEEK function
off_t lseek(int fd, off_t offset, int whence);
● // Successfully returned new file offset, error returns -1
● Parameter introduction:
● 1FD: The file descriptor to be set;
● 2Offset: The corresponding interpretation relies on the parameter three;
● ③whence:
● When WHENCE is Seek_SET, the offset of the file is set to the OFFSET by the file.
● When WHENCE is SEEK_CUR, set the offset of the file to the current value plus OFFSET, and OFFSET can be negative;
● Close function
int close(int fd);
● Turn off the FD fingers and turn it off to return 0, and return -1.
Chapter VII
● VFORK () function
The function is similar to the fork () function function. But more thorough: the kernel no longer creates a virtual space to the child process, directly allows the child process to share the virtual space of the Parent process. When the behavior of the corresponding segment occurs in the parent child process, create a virtual space and assign physical space to the sub-process. After the VFORK () function creates a sub-process, the Parent process will block, and the child process will run first.
● The child process created by the vFork () function will share address space with the parent process (before calling the exec «function or the exit () function), at which point the child process, if the variable is used, the variable value of the parent process is directly modified. Therefore, the child process created by the vFork () function may cause interference to the parent process. In addition, if the sub-process is not called the EXEC function family function or an exit () function, the parent-child process will have a deadlock.
● The main difference between the fork () function and the vFork () function is as follows:
● 1.vfork () function guarantee the child process first, in the sub-process schedule Exec function family function or exit () function, the fate () function will be scheduled to run. If the child process needs to rely on the further action of the Parent process, a deadlock is generated.
● 2.Fork () function The process environment of the parent process is required, and the vFork () function does not need to completely copy the process environment of the parent process, before the sub-process calls the exec «function or the exit () function, the child process and the father Process sharing process environment (at this point, the child is equivalent to thread), the parent process is blocked
Chapter 8 Inter-Process Communication
No nameless pipe:
Two uses of Write functions
●int write(int handle, void buf, int nbyte);
● Buffet data, Handle is the file descriptor, BUF points to the memory pointer, nbyte is the specified number of bytes; the return value is -1 error
●write(const char str,int n);
Read function
●int read(int handle, void *buf, int nbyte);
● read () will transfer the files referred to by the parameter handle to the memory referred to by the BUF pointer. If the parameter nbyte is 0, read () does not have a function and returns 0. Return value
Источник