1.
linyux Redirects-------------
There are 3 redirects:
basicallt, when we run a command in terminal, below three filescreated.
standard input(stdin) and it has file descriptor number as 0
standard output(stdout) and it has file decriptor number as 1
standard error(stderr) adn it has file decriptor number as 2
Output(stdout -1)---
-output of a command is shown in terminal
- to route output in file using >
ex- hostname > file_name
- to append output in existing file using >>
ex- pwd>>file_name
Error(stderr-2)
if any command gives you error then it is constidered as stderr -2
-we coan redirect the error to a file:
ex- cd/root/2 > eoor_file
- To redirect both standard outpput adn error to file:
ex: cd/root/ > error_file 2>&1
Input(stdin-0)
Input is used when feeding file contents to a file
Ex:
cat < file_name
cat << EOF
2. Truncate command-----------------
The linux trauncate command if often used to shrink of extend the size of a file to
the specified size.
command truncate -s 10 filename
3. Combining and Splitting Files----------------
- Multiple files can be combined into one and
- One file ccan be split into multiple files
cat file1 fiel2 file3 > file4
split file4
4. sed command------------
it can perform lots of functions on file like searching, find and replace,
insertion or deletion
- Replace a string in file with a newstring
- find and delete a line
- Remove empty lines
- temove the first or n lines in file
-To replace tabs with spaces
-show defined lines from a file
- Substitute within vi editor
- and much more
sed -i 's/Sarna/sarna/g' filename // replace Sarna to sarna
sed -i 's/Sarna//g' filename // replace Sarna
sed '/^$/d' filename // remove empty line
5. systemctl command--------------------
-its a new tool to control system services.
6.at command-------------
-at command is like corntab which allows you to schedule jobs but only once
-when the command is run it will enter interactive mode and you can get out by
pressing Ctrl D
usage:
- at hh:mm pm = schedule a job
- atq = list the at entries
- atrm # = remove entry
- atd = at daemon/service that manages scheduling
- systemctl status atd = To manage atd service
Create at entry scheduling a task:
at 4:45pm -> enter
echo "this is my first at entry" > at-entry
Crtl D
7. log monitoring-------------------
log directory= /var/log
commands-
boot
chronyd = NTP
cron
maillog
xecure
messages
gttpd
8. System maintenance commands--------
shutdown
init
reboot
halt
9. changing system hostname-----------
commands
hostnamectl - set-hostname newhostname
file that keep the hostname information is cat/etc/hostname
10. System architecture---------------------
Difference between a 32 bit and 64 bit CPPY
- A big difference between 32 bit processors and 64 bit processors is the number of
claculations per second they can perform, which affects the speed at which they can
cpmplete tasks.
to check the bit of linux mechine use commmand - arch