- The ls is the most widely used command in unix or linux.
- The ls command is a command-line utility for listing the contents of a directory or directories given to it via standard input.
Showing posts with label UNIX. Show all posts
Showing posts with label UNIX. Show all posts
Sunday, 12 November 2017
ls Command
Tuesday, 10 October 2017
cat command
cat command is use to read the contents of files or displaying them, combining copies of files and creating file .See the use of cat command
| Command | Details |
|---|---|
| cat [options] [filenames] [-] [filenames] | Syntax |
| cat file1 | cat command is use to read the contents of files |
| cat file1 > file2 | ">" this is output redirection operator, cat file1 output is written to file2 |
| cat >file1 | To Write the data into file 1 |
| cat > file2 | To Write the data into file 2 |
| cat file1 file2 | concatenate copies of the contents of the two files file1 and file2 |
| cat file1 file2 >file3 | file1 and file2 data redirect to file3 |
| cat >> file4 | ">>" the append operator , append the data in file4 |
touch command
In Unix and Linux touch command use for creating empty file,updating access time and modification time.| Command | Desc |
|---|---|
| syntax | touch [option] file_name(s) |
| touch file1 file2 file3 | This command would create three new empty files. |
| touch -am file3 | access(-a) and modification(-m) times to the current time |
| touch -r file4 file5 | [-r] is use for reference , to use the times of fille4 for file5 |
| touch -d '1 May 2005 10:22' file8 | To change the last access time of file8 to 10:22 a.m. May 1, 2005 |
| touch -d '14 May' file9 | [-d] Partial date change Only the date need be provided. |
Alias Command in Unix and Lunix
- Alias is a shortcut to reference a command.
- It can be used to avoid typing long commands that are frequently used.
- For common patterns it can reduce keystrokes and improve efficiency.
A user want to delete a file with confirm delete option for that we type
rm -i file.txt
remove file.txt? y
But some time we forgot to write -i , to avoid this such issue we use alias.
| Command | Desc |
|---|---|
| Syntax Of alias | alias [-p] [name="value"] |
| Example: | |
| alias | It will show you list of alish which is present in system |
| alias ls="ls -al" | lists the names of the files and directories within the current directory |
| alias df="df -h" | size, amount of space used, amount of space available (-h) in MB and GB |
| alias rm="rm -i" | increasing the safety of the system by making commands interactive. It is use for remove files |
| alias cp="cp -i" | increasing the safety of the system by making commands interactive .It is use for copy files |
| Removing Aliases | |
| Syntax | unalias [-a] name(s) |
| Example: | unalias rm |
Unix and Linux Basic Commands
Below are details of Basic Commands
| Command | Description |
|---|---|
| date | date command is used to print or set the system date and time. Syntax: date options |
| cal | cal displays a simple calendar. If arguments are not specified, the current month is displayed. Syntax: cal options |
| clear | clear the terminal screen |
| pwd | pwd command is used to print name of working directory |
| uname | print system information. Generally used to know the flavor and version of the operating system |
| who | show who is logged on |
| uptime | Tell how long the system has been running. |
| ls | If you simply execute ls on the command prompt, then it will display the files and directories in the current directory.You can pass a directory as an argument to ls command. In this case, the ls command prints all the files and directories in the specific directory you have passed.Syntax: ls directory |
| touch | The touch command simply creates an empty file. The below touch command creates a file_name.txt in the current directory.Syntax: touch file_name.txt |
| cat | The cat command is used to display the contents in a file. Syntax: cat file_name.txt |
| head | The head command can be used to print the specified number of lines from the starting of a file. Syntax: head -3 file_name.txt |
| tail | The tail command can be used to print the specified number of lines from the end of a file. Syntax: tail -3 file_name.txt |
| mkdir | The mkdir command is used to create the specified directory. |
| cd | The cd command can be used to change from one directory to another directory. You need to specify the target directory where you want to go. |
| mv | The mv command is used to rename the files and it also used for moving the files from one directory into another directory. |
| cp | The cp command is used to copy the content of source file into the target file. If the target file already have data, then it will be overwritten. |
| rmdir | remove or delete directories. Syntax: rmdir directory_name |
| wc | wc command can be used to find the number of line, words and characters in a file. |
| cut | cut remove sections from each line of files. Syntax: cat new_file.txt|cut -c1 |
| man | If you want to know more about all above command then go to man comman Syntaxman command_name. |
Monday, 9 October 2017
File Attributes and Permissions
File Attributes
We can observe 7 attribute fields listed for each file. The attribute fields are
- File name
- Modification date
- Size
- Group:(associated group for the file)
- Owner
- Number of links(the number of other links associated with this file),
- Permission modes: the permissions assigned to the file for the owner, the group and all others.
The permission field for each file consists of 10 characters as described by the diagram below
Unix File System
The Unix file system has a hierarchical (tree-like) structure with its highest level directory called root ( /).
Immediately below the root level directory are several sub-directories, most of which contain system files.
The following figure shows a typical organization of files in Unix system.
bin - short for binaries, this is the directory where many commonly used
executable commands reside
dev - contains device specific files
etc - contains system configuration files
home - contains user directories and files
lib - contains all library files
mnt - contains device files related to mounted devices
proc - contains files related to system processes
root - the root users' home directory (note this is different than /)
sbin - system binary files reside here. If there is no sbin directory on your system, these files most likely reside in etc
tmp - storage for temporary files which are periodically removed from the filesystem
usr - also contains executable commands
Unix File Types
All files in the Unix file system can be loosely categorized into 3 types, specifically:
- ordinary files
- directory files
- device files
Ordinary Files
Ordinary files hold data and executable programs. Executable programs are the commands
(ls) that you enter on the prompt. The data can be anything and there is no specific format
enforced in the way the data is stored.
The regular files can be visualized as the leaves in the UNIX tree.
Directories
Directories are files that contain other files and sub-directories. Directories are used to
Directories
Directories are files that contain other files and sub-directories. Directories are used to
organize the data by keeping closely related files in the same place. The directories are
just like the folders in windows operating system.
The kernel alone can write the directory file. When a file is added to or deleted from this directory, the kernel makes an entry.
A directory file can be visualized as the branch of the UNIX tree.
Special Or Device Files
These files represent the physical devices. Files can also refer to computer hardware such as terminals and printers. These device files can also refer to tape and disk drives, CD-ROM players, modems, network interfaces, scanners, and any other piece of computer hardware. When a process writes to a special file, the data is sent to the physical device associated with it. Special files are not literally files, but are pointers that point to the device drivers located in the kernel. The protection applicable to files is also applicable to physical devices.
User Login Process
When the user is trying to logging into system then Kernel should know who is that user.Kernel manage this user logging process by running below programs
- getty
- loging
[getty is short for “get terminal”.]
- Kernel calls program ‘init’. ‘init’ calls program ‘getty’, which issues a login prompt in the monitor.
- User enters login and password.‘getty’ calls program ‘login’ which scans file /etc/passwd to match username and password.
- After validation, control passes to session startup program /bin/sh .User gets a shell prompt.
- If the user fails to provide valid password, the login program returns the control back to the getty program.
What is UNIX ?
UNIX is a operating system which is multi user (multiple user can access Unix system at a sametime ) and multitasking (One user can run multiple program). Operating System is an interface
between hardware and applications software's.
Unix Architecture
1.Shell
- Human interface point for Unix
- Program layer – provides an environment for the user to enter commands to get desired results.
- Korn Shell, Bourne Shell, C Shell are various shells used by Unix users
- Heart of The Unix OS.
- Collection of C programs directly communicating with hardware
- Part of Unix system loaded into memory when Unix is booted
- System resources
- Allocates time between user and processes
- Decides process priorities
Unix Boot Process Setps
- BIOS : Basic I/O System Executes MBR.
- MBR : Master Boot Record Executes GRUB.
- GRUB : Grand Unified Boot loader executes Kernel.
- Kernel : Kernal executes sbin/Init.
- Init : Init executes run level programs .
- Runlevel : Runlevel program executes from /etc/rc .d/rc*.d/rc*.
Friday, 6 October 2017
Unix
Basic Concepts Of Unix⇨What is Unix?
⇨User Login Process
⇨Unix File System
⇨File Attributes and Permissions
Most Frequently Used UNIX / Linux Commands
⇨Basic Commands
⇨alias
⇨touch
⇨cat
⇨ls
Subscribe to:
Posts (Atom)


