Skip to main content

NFS

NFS (Network File System) is basically developed for sharing of files and folders between Linux/Unix systems by Sun Microsystems in 1980. It allows you to mount your local file systems over a network and remote hosts to interact with them as they are mounted locally on the same system. With the help of NFS, we can set up file sharing between Unix to Linux system and Linux to Unix system.

File Commands

# Copy source_directory recursively to destination. If destination exists, copy source_directory into destination, otherwise create destination with the contents of source_directory.
cp -r source_directory destination

# Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory file2
mv file1 file2

# Create symbolic link to linkname
ln -s /path/to/file linkname

# Create an empty file or update the access and modification times of file.
touch file

# Browse through a text file
# less is most useful for viewing the content of large files or the results of commands that produce many lines of output.
less file

# Display the first & last 10 lines of file
head file
tail file

# Display the last 10 lines of file and "follow" the file as it grows.
tail -f file

Useful tips

How do I run a shell script without using “sh” or “bash” commands?

  • Add a "shebang" at the top of your file: #!/bin/bash
  • And make your file executable (chmod +x script.sh).
  • Finally, modify your path to add the directory where your script is located (typically, you want $HOME/bin for storing your own scripts): export PATH=$PATH:/appropriate/directory

Why my cd command in makefile doesn't work?

When you write a cd some_directory. It is actually executing the command, changing the directory to some_directory, however, this is performed in a sub-process shell, and affects neither make nor the shell you're working from.

If you're looking to perform more tasks within some_directory, you need to add a semi-colon and append the other commands as well. Note that you cannot use newlines as they are interpreted by make as the end of the rule, so any newlines you use for clarity needs to be escaped by a backslash.

all:
cd some_dir; echo "I'm in some_dir"; gcc -Wall -o myTest myTest.c

pushd command to change directory

In a Makefile, use pushd to change directories temporarily and then return to the original directory with popd. Here's a concise example:

SHELL := /bin/bash

.PHONY: build clean

build:
@echo "Building project"
@pushd src > /dev/null && $(MAKE) all && popd > /dev/null

clean:
@echo "Cleaning project"
@pushd src > /dev/null && $(MAKE) clean && popd > /dev/null
  • SHELL := /bin/bash: Ensures the Makefile uses Bash.
  • pushd src > /dev/null && $(MAKE) all && popd > /dev/null: Changes to src, runs make all, then returns to the original directory. > /dev/null suppresses output.

NTFS vs ext4

NTFS (New Technology File System) and ext4 (Fourth Extended File System) are two different file systems used in different operating systems. Here's a comparison of NTFS and ext4:

NTFS:

  • Origin: NTFS was developed by Microsoft and is the default file system used in Windows operating systems.
  • Features: NTFS offers advanced features like support for large file sizes, file compression, file encryption, access control lists (ACLs), and journaling, which helps in recovering from system crashes or power failures.
  • Compatibility: NTFS is primarily used on Windows systems. It has limited support on other operating systems, which may be read-only or require third-party tools for full access.
  • Performance: NTFS generally provides good performance, especially on Windows systems. It's optimized for use on modern hardware and supports features like defragmentation.
  • Limitations: NTFS has limitations when it comes to full interoperability with non-Windows systems. Its advanced features might not be fully accessible on other platforms.

ext4:

  • Origin: ext4 is a widely used file system in the Linux ecosystem and is the successor to ext3.
  • Features: ext4 offers features like support for large file sizes, journaling for better recovery, improved performance through delayed allocation, and support for extents (contiguous ranges of blocks) which helps improve file storage efficiency.
  • Compatibility: ext4 is the default file system for many Linux distributions. While it is natively supported on Linux systems, it may not be fully supported on Windows or other operating systems without third-party tools.
  • Performance: ext4 is known for its solid performance on Linux systems. It is well-suited for a wide range of workloads and use cases.
  • Limitations: Like NTFS, ext4 may have limitations when it comes to cross-platform compatibility. While ext4 can be accessed on Windows systems with third-party tools, it may not fully support all ext4 features.

In summary, NTFS and ext4 are both modern file systems that offer various features for managing files, but they are associated with different operating systems (Windows for NTFS and Linux for ext4). When choosing between them, consider the platform you're working with, the specific features you need, and the compatibility requirements for your data and applications.