Please enable JavaScript.
Coggle requires JavaScript to display documents.
Linux, Tricks, Localization and Internationalization, Operators
link,…
Linux
Command line
-
quoting
-
-
-
type {tells you teh type of command, Ex type ls}
-
-
-
Basic File Management
-
-
-
-
-
-
-
find { file . -name 'file.txt", file /user -maxdepth 2 -name 'file.txt" , -mmin 60 search fiel modified in last 60 min}
tar {-c create, -v verbose, -f specify filename, -x this compress}
dd -if -of [options] {this is a data duplicator utility, used by sysadmins to take backups}
-
-
Streams
STDIN 0
STDOUT 1
STDERR 2
-
XARGS
{Below command deleted all files in teh system by the name of blah .txt
$ find / -name blah.test |xargs rm
-
-
Job Priority
nice {nice value, priority}
Regex
-
Quantifiers
-
-
-
-
-
{min, max} min and max of the precedign elements
-
-
-
-
-
orphan pointers
-
:red_flag:most recent ......
- API support
- Concurrent Processing
-
-
-
-
Boot system
-
GNU /GRUB :star:
KERNAL
Init
-
-
-
-
command
DMESG
- T shows the readable data
-
- /dev/sda Harddisk name generally
Tricks
- diff <(ls /original/dir/) <(ls /backup/dir/)
diff is a tool that typically compares two text files line by line, looking for differences. Here it gets the output from two ls commands and treats them as if coming from a file and compares them as such.
sort -r <(while read -r name surname films;do echo $films $name $surname ; done < CBactors)
if you can take the output of a command or command line, make it look like the contents of a file, and feed it to an instruction that is expecting a file, that means that in the sorting by favorite actor example from above, you could’ve done away with the intermediate file and just piped the output from the loop into sort
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Ampersand Operator (&) The function of ‘&‘ is to make the command run in background. Just type the command followed with a white space and ‘&‘. You can execute more than one command in the background, in a single go. tecmint@localhost:~$ ping c5 www.tecmint.com & root@localhost:/home/tecmint# apt-get update & apt-get upgrade &
- semi-colon Operator (;)The semi-colon operator makes it possible to run, several commands in a single go and the execution of command occurs sequentially. root@localhost:/home/tecmint# apt-get update ; apt-get upgrade ; mkdir test The above command combination will first execute update instruction, then upgrade instruction and finally will create a ‘test‘ directory under the current working directory.
- AND Operator (&&) The AND Operator (&&) would execute the second command only, if the execution of first command SUCCEEDS, i.e., the exit status of the first command is 0. This command is very useful in checking the execution status of last command. For example, I want to visit website tecmint.com using links command, in terminal but before that I need to check if the host is live or not.root@localhost:/home/tecmint# ping -c3 www.tecmint.com && links www.tecmint.com
- OR Operator (||) The OR Operator (||) is much like an ‘else‘ statement in programming. The above operator allow you to execute second command only if the execution of first command fails, i.e., the exit status of first command is ‘1‘.For example, I want to execute ‘apt-get update‘ from non-root account and if the first command fails, then the second ‘links www.tecmint.com‘ command will execute. tecmint@localhost:~$ apt-get update || links tecmint.com In the above command, since the user was not allowed to update system, it means that the exit status of first command is ‘1’ and hence the last command ‘links tecmint.com‘ gets executed. What if the first command is executed successfully, with an exit status ‘0‘? Obviously! Second command won’t execute.tecmint@localhost:~$ mkdir test || links tecmint.com Here, the user creates a folder ‘test‘ in his home directory, for which user is permitted. The command executed successfully giving an exit status ‘0‘ and hence the last part of the command is not executed.
- NOT Operator (!)The NOT Operator (!) is much like an ‘except‘ statement. This command will execute all except the condition provided. To understand this, create a directory ‘tecmint‘ in your home directory and ‘cd‘ to it.tecmint@localhost:~$ mkdir tecmint tecmint@localhost:~$ cd tecmintNext, create several types of files in the folder ‘tecmint‘. tecmint@localhost:~/tecmint$ touch a.doc b.doc a.pdf b.pdf a.xml b.xml a.html b.htmlSee we’ve created all the new files within the folder ‘tecmint‘.tecmint@localhost:~/tecmint$ ls a.doc a.html a.pdf a.xml b.doc b.html b.pdf b.xmlNow delete all the files except ‘html‘ file all at once, in a smart way.tecmint@localhost:~/tecmint$ rm -r !(*.html)Just to verify, last execution. List all of the available files using ls command. tecmint@localhost:~/tecmint$ ls a.html b.html
- PIPE Operator (|)This PIPE operator is very useful where the output of first command acts as an input to the second command. For example, pipeline the output of ‘ls -l‘ to ‘less‘ and see the output of the command.tecmint@localhost:~$ ls -l | less
- Command Combination Operator {}Combine two or more commands, the second command depends upon the execution of the first command.For example, check if a directory ‘bin‘ is available or not, and output corresponding output.tecmint@localhost:~$ [ -d bin ] || { echo Directory does not exist, creating directory now.; mkdir bin; } && echo Directory exists.
- Precedence Operator ()The Operator makes it possible to execute command in precedence order.Command_x1 &&Command_x2 || Command_x3 && Command_x4.In the above pseudo command, what if the Command_x1 fails? Neither of the Command_x2, Command_x3, Command_x4 would executed, for this we use Precedence Operator, as:(Command_x1 &&Command_x2) || (Command_x3 && Command_x4)In the above pseudo command, if Command_x1 fails, Command_x2 also fails but Still Command_x3 and Command_x4 executes depends upon exit status of Command_x3.
- Concatenation Operator ()The Concatenation Operator () as the name specifies, is used to concatenate large commands over several lines in the shell. For example, The below command will open text file test(1).txt.
- AND – OR operator (&& – ||)The above operator is actually a combination of ‘AND‘ and ‘OR‘ Operator. It is much like an ‘if-else‘ statement.For example, let’s do ping to tecmint.com, if success echo ‘Verified‘ else echo ‘Host Down‘.tecmint@localhost:~/tecmint$ ping -c3 www.tecmint.com && echo "Verified" || echo "Host Down"Sample OutputPING www.tecmint.com (212.71.234.61) 56(84) bytes of data. 64 bytes from www.tecmint.com (212.71.234.61): icmp_req=1 ttl=55 time=216 ms 64 bytes from www.tecmint.com (212.71.234.61): icmp_req=2 ttl=55 time=224 ms 64 bytes from www.tecmint.com (212.71.234.61): icmp_req=3 ttl=55 time=226 ms --- www.tecmint.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2001ms rtt min/avg/max/mdev = 216.960/222.789/226.423/4.199 ms Verified Now, disconnect your internet connection, and try same command again.tecmint@localhost:~/tecmint$ ping -c3 www.tecmint.com && echo "verified" || echo "Host Down"Sample Outputping: unknown host www.tecmint.com Host Down
-
MTA
Mail transfer agent
-
-
-
-
-
apt-get install postfix mutt
- Mutt is an email program to send and receive emails.
-
-
-
at
- this command can be used to email of ps-aux etc output on a future time
-
Commands
-
-
-
-
-
modprobe: to add module, Ex: sudo modprobe video
rmmode: remove a module. ex: sudo rmmod video , (removes video modules)
maintaining system time
date
- shows time from /
- the date is stored in epoc in no of seconds
- data +%s this command shows the no of seconds
ntpdate
- install ntpdate
- this contantly pools the ntp servers arounds teh globs to maintain the system time
-
hwclock
his shows the hardware clock of a linux machine
- to set tehhardware to system clock, use the below command:
- sudo hwclock --systohc (this takes the system time and sets the hardware clock)
-
SystemLogging
syslog
- System Management
- Security Auditing
- General Information
- Analysis
- Debugging messages
-
-
. (dot)
- it means “this directory” link
-
find . -name "*.jpg"
“find in this directory (and all its subdirectories) files that have names that end in .jpg“.
Also you use . as a command. Yep! You heard me: . is a full-fledged command. It is a synonym of source and you use that to execute a file in the current shell, as opposed to running a script some other way (which usually mean Bash will spawn a new shell in which to run it)
double dot.
- Apart from pointing to the parent of the current directory, the double dot (..) is also used to build sequences.
- It will print out the list of numbers from 1 to 10. In this context, .. means “starting with the value on my left, count up to the value on my right“.
echo {1..10..2}
- You’ll get 1 3 5 7 9. The ..2 part of the command tells Bash to print the sequence, but not one by one, but two by two. In other words, you’ll get all the odd numbers from 1 to 10.
echo {1..10..2}
- It works backwards, too:
echo {10..1..2}
- You can also pad your numbers with 0s. Doing:
echo {000..121..2}
- you want to create directories in which to classify your digital invoices of the last 10 years:
mkdir {2009..2019}_Invoices
- you want to remove only every third frame between the frames 43 and 61:
rm frame_{043..61..3}
- if you have more than 100 frames, they will be named with padded 0s and look like this:
frame_000 frame_001 frame_002 ...
curly braces ({})
- creates the files file_a.txt through file_z.txt.
touch file_{a..z}.txt
- Creates blahg_file.txt, splurg_file.txt and mmmf_file.txt.
touch {blahg, splurg, mmmf}_file.txt
TimeManagements
crony
- versitile implementation od network clock protocol
- can referecne GPS
- can use manual clock
- designed to perform in a wide range of condition.
- changeng temperatire
- virtual machine
- Intermittant network conditiona.
-
-
swap
[space where RAM swaps when its full, no one access this space]
-
LVM[ Logial Volume Manager:
- helps to create disk into pools
- can create partitions from pool
- can grow or shrink]
-
-
"<" input
Example: $ sort < country.list
$ sort < END
- to trick a tool into believing the output of a command is data from a file.
-
Journald and systemd
rsyslog
- system logging implementation
- can be configured to receive logs from systemd-journal
-
:
:
-
-
-
-
-