If you can see this check that

next section prev section up prev page next page

Standard Input/Output and Redirection

Unix uses the keyboard and the terminal screen for its standard input and output devices. It always expects input from the keyboard and sends output to the terminal unless you tell it differently. You can send any screen output to a file in your directory by using redirection in the command line to redirect the output from the terminal screen to a file. The redirection symbol is the greater than sign '>'. If the file does not exist then it is created for you. For example:


Create demo account

User:
Password:

To follow along with the examples shown here using the virtual machines is it safer to use an account other than the administration account (root). By pressing the button below a new account is created called "demo", password is also "demo". Log in using this account and you cannot do any damage. If you mess the account up and want to start again, just press the button again.

Once created, you can log into this account using telnet or ssh, logging into the hostname linuxzoo.net. Remember the username is demo and the password is demo. And remember, you cannot break anything using this account! The account begins with an empty directory, so dont be shocked that "ls" shows nothing...

To reset all the check buttons from a previous attempt click here

Question 1: Create demo account

Create the demo account.

Tests - not attempted
Create an account called demo, password demo UNTESTED

% cal > myfile
% cat myfile

If the file myfile has existed then its contents would have been erased. Information however can be appended to the end of a file by using two greater-than signs '>>', but the file must exist for this to work. For example:

% cal 3 1991 >> myfile
% cat myfile

To verify that myfile is created and exists in your directory, run the ls command.

The cat command is commonly used to print the contents of files. Its name arises from the ability to take many file name arguments and concatenate them (combine files). Thus to merge several files one after the other into a single file:

% cat file1 file2 file3 > bigfile

Many Unix commands accept options which are generally single character entries that specify a variation in the basic command. While a hyphen must usually precede the first option, you can combine options in any sequence and group them together to form a word beginning with a hyphen. The ls command is a good example of a command that uses options, the most frequently used of which is -l ('l' as in letter). This option produces a long listing, as in the example given below:

% ls -l
-rwxr-xr-x.1jsmithusers567Nov 18 12:25myfile
PermissionsLinksownergroupbytescreation datefilename

Each directory contains hidden files in addition to the names you see displayed. if you specify the -a option in the command, you will see the hidden file names as well as the standard ones. Hidden names are simply filenames which begin with a period '.'. This is a good way of hiding files which you do not want to see on a regular basis when you look at a directory listing of that directory. For example, you will have two or more hidden start-up files that the system runs when you log in:

% ls -a
.login     .cshrc    myfile

Centos 7 intro: Paths | BasicShell | Search
Linux tutorials: intro1 intro2 wildcard permission pipe vi essential admin net SELinux1 SELinux2 fwall DNS diag Apache1 Apache2 log Mail
Caine 10.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Mock Exam |
Caine 13.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Registry | Mock Exam |
CPD: Cygwin | Paths | Files and head/tail | Find and regex | Sort | Log Analysis
Kali: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7a | 8a | 8b | 9 | 10 |
Kali 2020-4: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7 | 8a | 8b | 9 | 10 |
Useful: Quiz | Forums | Privacy Policy | Terms and Conditions

Linuxzoo created by Gordon Russell.
@ Copyright 2004-2024 Edinburgh Napier University