Bash Index : F - The 'F' Bash commands : description, flags and examples


  • I've been mislead into thinking than avconv obsoleted ffmpeg (details), which is why most of my examples are based on avconv whereas ffmpeg still is the right tool for audio/video-related tasks.
  • Hopefully, both tools are compatible with each other, and using either avconv or ffmpeg in command lines should do the job .


Resume the specified job in the foreground, and make it the current job.
fg takes a job ID —available from jobs— not a PID.
If no job ID is specified, the shell's notion of the current job is used (usually the most recent one).


Usage :

fc is a utility that can, like history :

Flags :

Flag Usage
-e -l -n -l flags and options for the "select" mode (not detailed here so far)
-s search=replacement command This is the "replay" mode :
  • command :
    • defaults to the previous command, so anything as short as fc -s just replays the previous command
    • otherwise : replays the previous command starting with command (this reads the commands history from newest to oldest and picks the first match)
  • search=replacement : replace search with replacement in the selected command (either the previous or the one starting by ...(read above )), then replay the edited command
    Don't forget the = sign between search and replacement.
Looks like successful fc -s commands are not recorded in the history.

Example :

Fix my poor typing :

There's a typo I make quite often : while trying to run, I type
instead of :
fc can help here :
  1. alias '::'='fc -s ".:"="./"'
  2. So the next time I type
    I'll get
    bash: command not found
  3. Then, using my new alias :
    fc fixes the typo and runs the command
    (normal output of


Usage :

factor x y z prints the prime factors of each specified integer.

Example :

factor 8 17 42

8: 2 2 2
17: 17
42: 2 3 7


Usage :

Determine file type.

Flags :

Flag Usage
(none) Simply output the file type :
  • ASCII text, UTF-8 Unicode text
  • POSIX shell script text executable, Korn shell script text executable
  • JPEG image data, JFIF standard 1.01
  • ...
This also adds with CRLF line terminators when testing text files made on Windows.
-i --mime Output mime type strings rather than the more traditional human readable ones. Thus it may say text/plain; charset=us-ascii rather than ASCII text.


Usage :

Partition table manipulator for Linux

Flags :

Flag Usage
-l device
list the partition tables of devices mentioned in /proc/partitions, then exit.
list the partition tables for device, then exit.

Example :

WARNING: Re-reading the partition table failed with error 16: Device or resource busy. after running fdisk on Red Hat :

Looks like everything you have to do is run :

source :


Do nothing, and fail
false only returns a Unix-failure exit code : non-zero.


Flags :

Command Usage
ftp host open an ftp session on the distant server host
Use either your personal login/password or anonymous/[Enter]
ftp -s:commands.txt automatically run the commands from commands.txt (works only with Windows FTP)
get fileName download fileName to current local directory
mget * download all the files of the remote directory to the local directory
put fileName upload fileName to current remote directory
mput * upload all the files of the local directory to the current remote directory
delete fileName delete the specified remote file
mdelete delete multiple files
prompt Toggle interactive prompting. Interactive prompting occurs during multiple file transfers to allow the user to selectively retrieve or store files. By default, prompting is turned on. If prompting is turned off, any mget or mput will transfer all files, and any mdelete will delete all files.
binary / ascii toggle binary / ascii file transfer mode :
  • ASCII : for pure text files ( = that can be handled by simple text editors)
  • binary : compiled or assembled code such as executables or data files.
The FTP protocol shrinks files before transmission, which is done through dedicated algorithms depending on the file type: either ASCII or binary. Actually, ASCII files have a higher compression rate than binaries. Use ASCII transfer only if you're sure that the content to be sent is an ASCII file, otherwise default to binary.
rename remoteFile1 remoteFile2 rename the remote file called remoteFile1 into remoteFile2
lcd localDirectoryName change to local directory localDirectoryName
! mkdir localDirectoryName create the local directory localDirectoryName
open re-open connection after time-out disconnect (still in ftp prompt: ftp> _ )

Example :

Connect to a secure FTP (SFTP) server :

Use cURL


Usage :

Identify processes (PID) using specific files or sockets

Without root privileges, fuser won't display anything if the corresponding PID is not yours.

Flags :

Flag Usage
-a --all Show all files specified on the command line. By default, only files that are accessed by at least one process are shown.
-k -signal myFile Send signal signal to process(es) accessing myFile. If signal is omitted, SIGKILL is sent.
With -i : prompt before killing a process.
-m myFile List processes accessing files that are on the same filesystem than myFile. It also displays Frcem flag to identify the access type.
-v verbose

Example :

Get the webserver's PID :

fuser 80/tcp

List processes using port 443 :

fuser -va 443/tcp

List processes accessing the /home partition :

fuser -va /home


Usage :

Display amount of free / used memory (by reading /proc/meminfo).

Flags :

Flag Usage
-b / -k / -m / -g display amounts in bytes / kilobytes / megabytes / gigabytes
-t display a "total" line

Example :

basic usage : free -m

		total	used	free	shared	buffers	cached
Mem:		16085	15884	200	0	347	12940
-/+ buffers/cache:	2596	13489
Swap:		1951	0	1951
  1. the 1st row (Mem:) is about physical memory utilization, including the amount of memory allocated to buffers and caches.
  2. the 2nd row (-/+ buffers/cache:) shows the amount of physical memory currently devoted to system buffers and cache. This is particularly meaningful with regard to application programs, as all data accessed from files on the system that are performed through the use of read() and write() system calls pass through this cache. This cache can greatly speed up access to data by reducing or eliminating the need to read from or write to the HDD or other disk.
Interpreting numbers :
  • 16085 MB of RAM are installed in the machine
  • 15884 MB of RAM are used, meaning there's something written there by someone for someone
  • 200 MB of RAM are free : there's nothing written there. This space is somehow wasted
  • 0 MB of RAM are shared. "Shared" memory is data or code that is common to several processes (i.e. : several instances of a shell console). This column is now obsolete
  • 347 MB of RAM are used for disk buffering
  • 12940 MB of RAM are used to cache data and make the system faster
  • used - buffers - cached = 15884 - 347 - 12940 = 2597 : amount of used RAM in the -/+ buffers/cache: row
  • used + free = 15884 + 200 = 2596 + 13489 = 16085 = total
buffers and caches :
  • buffer : a portion of memory that is set aside as a temporary holding place for data that is being sent to or received from an external device, such as a HDD, keyboard, printer or network.
  • cache : every time data is read from a file on disk, it's read into memory, and goes into the cache. After this, the kernel has the option to discard the cache.