UNIX is an operating system that first started in 1960s. It has seen a lot of improvements and upgrades that up until today, many people prefer to use it for its stability. It can also be used as a server where it can support many users and enable you to do various tasks at the same time.
UNIX Operating System
The operating system of UNIX is made up of three parts:
- Kernel is the core of the operating system. This is where time and memory are allocated to programs.
- The shell acts as the interface between the user and the kernel. The shell is the command line interpreter so that whenever a user types in something, it interprets and carries out the command.
- The commands are the programs. When a program is closed or terminated, the shell prompts the user.
Commands for Listing Files and Directories
Upon logging in, the first directory that you will see will be your home directory where you can see your username. This is where your personal files and subdirectories can be seen.
The following are the commands used in accessing files and directories. The case should be used as is.
- ls – Lists files and directories. If you have created a new directory, you can use this command to view it.
- ls –a – This command lists all the files and directory.
- mkdir – This is the command used if you are going to create a directory.
- cd directory – Use this command to change to the named directory.
- cd and cd ` – Command used to change to home directory.
- cd . . – Use this command to change to parent directory.
- pwd – This command is used to display the path of the current directory.
Commands for Copying, Removing and Renaming Files
These are the useful commands for manipulating files. To use this, substitute file1 and file2 with the actual file name.
- cp file1 file2 – This command is used to copy file1 and call it file2.
- mv file1 file2 – Command used in moving or renaming file1 to file2.
- rm file – Use this command to remove a file.
- rmdir directory – Command used if you want to remove a directory.
- cat file – Use this command to show a file.
- less file – If you want to display a file a page at a time, this is the command to use.
- head file – To show the first few lines of a file the head command is used.
- tail file – If you want to display the last lines of a file, use the tail command.
- grep ‘keyword’ file – This command is useful if you want to search a file for keywords.
- wc file – To know number of lines/words/characters in file, wc command is used.
- diff file1 file2 – Shows the difference between files.
Commands Used to Find Things
- ff – Command used to find files in the system. This is very useful in case you have forgotten the directory where you stored the file but you know the name.
- ff –p – This command can be used to search for the beginning of the file name without typing the whole name.
- grep string filename(s) – Command that searches for a string in the files.
File Compression Commands
- gzip filename – Command used to compress files to take up lesser space. The size of the file varies with the compression but it can be compressed up to half of the original size.
- gunzip filename – Command used to uncompress files compressed by gzip.
- gzcat filename – Command used to allow you to look at a gzipped file without having to gunzip it.