Server Administration 1
Linux
Basic Linux Concepts
- Everything in Linux is a file
- Linux File System
Linux Standard Base (LSB)
The goal of the LSB is to develop and promote a set of open standards that will increase compatibility among Linux distributions and enable software applications to run on any compliant system even in binary form. In addition, the LSB will help coordinate efforts to recruit software vendors to port and write products for Linux Operating Systems.

- LSB Core Specifications
- Base Libraries
- Utility Libraries
- C++ Libraries
- Executable And Linking Format (ELF)
- Low Level System Information
- Commands and Utilities (grep, sed, awk, tar, useradd, patch, etc.)
- Execution Environment
- File System Hierarchy (Filesystem Hierarchy Standard)
- Localization
- Package Information, Format and Installation
- Users & Groups (names, id, etc.)
- System Initialization (cron, init scripts, etc.)
- Network Security Services
- LSB Desktop Specifications
- Graphic Libraries (libX11, libSM, libICE, libXt, libXext, libXi)
- OpenGL Libraries
- Picture libraries (jpeg, png)
- Fontconfig library
- GTK+ Stack Libraries
- Qt Library
- LSB Runtime Languages Specifications
- Python Interpreter
- Perl Interpreter
- XML2 Library
- XSLT Library
- LSB Imaging Specifications
- Printing Library
- Printing Commands
- Scanning Library
The LSB contains both a set of Application Programming Interface (API) and Application Binary Interfaces (ABIs). APIs may appear in the source code of portable applications, while the compiled binary of that application may use the larger set of ABIs. A conforming implementation provides all of the ABIs listed here. The compilation system may replace (e.g. by macro definition) certain APIs with calls to one or more of the underlying binary interfaces, and may insert calls to binary interfaces as needed.
The LSB is primarily a binary interface definition. Not all of the source level APIs available to applications may be contained in this specification.
The Linux console is the first impression for most of the Linux users. You type the command and the system response to you. But, what is the underneath of the interactive console? How does it interact with the hardware and software?
Linux Files Input/Output (I/O)
As we always say, everything in Linux is a file. So, it is very important to understand the life of a file.
What is I/O?
Input and output are the basic concept of components in computer. We send input to a component and the component processes the input and gives output (as an input) for the next component or directly to the end user.
Programs: need to interact with the external world
Programs store data in files which provide large persistent storage.
In this post we will look at the system calls and functions for file I/O and the issues that govern the program and I/O device interaction.
Buffered I/O
Let’s look at some basic commands that report on memory usage. The first that probably comes to mind is free. The free command will tell you about used and unused memory and about swap space.
Physical memory is the random access storage provided by the RAM modules plugged into your motherboard.
Swap is some portion of space on your hard drive that is used as if it is an extension of your physical memory.
$ free -m
total used free shared buffers cached
Mem: 2026 1922 103 0 491 1109
total used free shared buff/cache available
Mem: 7973 6359 1389 17 223 1483
Swap: 24576 721 23854
The first line of the free command’s output contains the column headings.
Mem: displays information on how physical memory is being used. The -m option displays the information in terms of megabytes rather than kilobytes (the default). Just looking at these numbers, we see that this system has roughly 8 GB of RAM and around 6GB is used.
Swap: line in the output, we see that the swap space appears to be unused. This system has 24 GB of swap, three times the size of the physical memory.
buff/cache: This is probably the trickiest part of understanding free’s output. This shows how much of the physical memory is used by the buffer cache. In other words, this shows how much memory is being used (think “borrowed”) for disk caching. And don’t forget that you should like disk caching because it makes the system run much faster. So, while at first glance, this system appears to be running short of memory, it’s actually just making good use of memory that’s currently not needed for anything else. The key number to look at in the output above is, therefore, the 1483. This is the amount of memory that would be made available to your applications if they need it.
Adding a -t to the free command gives you a line of totals at the bottom. Look carefully and you’ll notice that the buff/cache figures are not considered in the totals line.
total used free shared buff/cache available
Mem: 7973 6406 1343 17 223 1437
Swap: 24576 720 23856
Total: 32549 7126 25199
If your system is busy and you want to watch how memory is changing, you can run free with a -s <seconds> argument that causes the command to give you totals every <seconds> seconds.
$ free -tms 10
total used free shared buff/cache available
Mem: 7973 6449 1299 17 223 1393
Swap: 24576 714 23861
Total: 32549 7164 25160
total used free shared buff/cache available
Mem: 7973 6422 1327 17 223 1421
Swap: 24576 714 23861
Total: 32549 7136 25188
total used free shared buff/cache available
Mem: 7973 6453 1296 17 223 1390
Swap: 24576 700 23875
Total: 32549 7154 25171
You would terminate the looping with a ^C. Another option is to use the watch command. This will give you a two-second updated display, You can change the interval used by the watch command by providing a -n <seconds>
(e.g.,free -n 10).
$ watch free -m
Every 2.0s: free -m
total used free shared buff/cache available
Mem: 7973 6235 1514 17 223 1608
Swap: 24576 710 23865
Another command that will provide you with some information on how your memory is being used is top. While top is command for looking at performance, even its memory statistics need a little interpretation.
$ top
top - 00:57:40 up 28 min, 0 users, load average: 0.52, 0.58, 0.59
Tasks: 4 total, 1 running, 3 sleeping, 0 stopped, 0 zombie
%Cpu(s): 8.3 us, 5.4 sy, 0.0 ni, 86.1 id, 0.0 wa, 0.2 hi, 0.0 si, 0.0 st
MiB Mem : 7973.8 total, 1691.5 free, 6058.3 used, 224.0 buff/cache
MiB Swap: 24576.0 total, 23864.4 free, 711.6 used. 1784.9 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 9788 528 484 S 0.0 0.0 0:00.12 init
9 root 20 0 9796 300 248 S 0.0 0.0 0:00.01 init
10 superjo+ 20 0 15076 2404 2324 S 0.0 0.0 0:00.07 bash
147 superjo+ 20 0 17920 2120 1508 R 0.0 0.0 0:00.04 top
Let’s begin with the first number on the Mem: and Swap: lines. These are the totals for RAM and swap space and should be consistent with the numbers that we get by looking at the output from the free command. The same holds true of the used and free figures on these lines. Where the top output gets a little confusing is in the buffers and cached figures. Note that we saw these number in the output of the free command, but they were associated with the Mem: statistics, With top, they’re on the Mem: and Swap: lines. But, no, these figures actually refer to two RAM statistics and describe aspects of physical memory.
buffers: In-memory blocks that result from the kernel accessing the disk, such as when the kernel needs to read the contents of files. The buffer figure increases when the file system layer is bypassed cached: RAM is being used to cache the content of recently read files. The cache grows when the file system is used or read operations increase .
cached: RAM is being used to cache the content of recently read files. The cache grows when the file system is used or read operations increase.
One last command that you might use when looking at memory use is vmstat. In vmstat output, you should see some of the same numbers, but in different places.
$ vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 128 106612 503380 1135668 0 0 2 2 3 2 0 0 100 0 0
The swpd figure shows used swap space while free shows free memory. The buff and cache figures are the same figures as the buffer and cached figured from free and top. What you don’t see are the numbers for overall memory size or the reassuring buff/cache that give you an idea how much flexibility your memory system can muster if there is demand for more memory.
The best command of checking free memory: free
– Can get a quick and accurate view of memory use on a Linux system
– Provide you factor in an understanding of what the buff/cache is telling you
Linux File Sync (fsync)
Linux File Errors
Linux File Events
Linux File Metadata
Linux File Read/Write
Linux Multiplex
Linux File Links
Linux File Iseek
Buffering
Next topics:
Linux Programming Concepts | Linux Interprocess Communications (IPC) | Linux Headers
POSIX Basics | Linux Access Rights
Linux Process Management
Linux Process / Child Process
Linux Process Priority
Linux Process Sessions
Linux Process Zombie
Linux Process Limits
Linux Process Fork
Linux Process Users and Groups
Linux Process PID and PPID
Linux Process Planning
Linux Signals
Linux Signals: LIST
Linux Signals: SEND Signal
Linux Signals: Management
Linux Threads
Linux P-Threads
Linux Multi-threads
Linux Thread Models
Linux Thread Concurrency
Linux: Time
Linux Time: System Time
Linux Time: Sleep and Wakeup
Linux Time: POSIX
Linux Time: Current Time
Linux Time: Timers
Linux Commands
Process Management
htop
kill
top
directory proc
File Management
touch
cd
du
stat
pwd
ls
cp
mv
mkdir
chmod
ln
rm
find
df
cat
chown
File Editors
nano
vim
pico
Text Processors
tail
echo
grep
awk
sed
Network Management
netstat
ping
tcpdump
Other
id
man
info
Windows
MacOS