SORT:
• -d (Uses dictionary sort order and ignores the punctuation)
• -f (Ignores caps)
• -i (Ignores nonprinting control characters)
• -m (Merges two or more input files into one sorted output)
• -r (Sorts in reverse order)
• -u (If line is duplicated only display once)
WC:
• -m (Print the byte counts)
• -l (Print the new line counts)
• -w (Print the word counts)
Head and Tail Command:
Help for Linux Commands:
● Top
● But, if the releasing doesn’t happen correctly, then, memory accumulation happens over a long time which results in a leak.
● Due to this, memory starvation happens for other process
● Go to bash and then $df or $df -h(df=diskspace for filesystem. Used to see flash and also all other filesystem mounts)
● It shows the log for currently running process
OTHER COMMANDS:
● If we want to get more space, we clear varcore and other logs
● To search for files, we use find command (it is important). For example, we can use find to find the debug.log file.
● Environment Variables - The binaries are stored at a specific location and whenever a process asks for the file, it tells to look at the specific location using environment variables. To see all env variables, use $printenv
● BASHRC file:
● Background and Foreground Process:
Here, While that is running in the background, the shell prompt will return.
Here, the next prompt will not appear until command1 finishes running.
● EOS maintains its own route tables.
● Loopback Address:
● Tcpdump:
sftp> get filename.pcap
sftp> exit
admin$ ls | grep filename.pcap
- ■ The Linux sort command can be used to sort the contents of a file in a number of ways. By default, the Linux sort command sorts the contents in alphabetical order depending on the first letter in each line. For example, the $sort /etc/passwd command would sort all users by username.
- ■ Important options of the sort are
• -d (Uses dictionary sort order and ignores the punctuation)
• -f (Ignores caps)
• -i (Ignores nonprinting control characters)
• -m (Merges two or more input files into one sorted output)
• -r (Sorts in reverse order)
• -u (If line is duplicated only display once)
- ○ Sorts the list of process in order of the 3rd column
- ○ Sorts the cat of two files on the first letter of each line
- ■ The Linux wc (word count) command, can return the number of lines, words, and characters in a file. Important options of the Linux wc command are
• -m (Print the byte counts)
• -l (Print the new line counts)
• -w (Print the word counts)
- ○ The “more” command is used to view text output of commands or files one page at a time. When the user is ready for the next block of text, they press the space bar.
- ○ Less extends the functionality of more by adding forward and backwards movement, the ability to search multiple files, view gzipped files without uncompressing them first, set marks for navigation and can invoke an editor when viewing files.
Head and Tail Command:
- ○ tail prints the last 10 lines of each FILE to standard output.: tail myfile.txt
- ■ To print last 100 lines, we can use tail myfile.txt -n 100
- ○ head, by default, prints the first 10 lines of each FILE to standard output.
Help for Linux Commands:
- ○ Man: If you don’t know the exact command name for a specific functionality, use man -k option to locate the command.
- ○ Whatis: To display a single line description about the command, you can use whatis command.
- cron (8) - daemon to execute scheduled commands (Vixie Cron)
- ○ Use -h or –help option of the command itself: Sometimes you may know the functionality of a command very well, but cannot recollect all the available options for a specific command. Use -h option of the command to review all available options of the command.
- ○ Info: When you are not able to find the required information from the Unix man page, try the info documents using the Unix info command as shown below.
● Top
- ○ Works like PS only
- ○ But, it is Real-time
- ○ Lists out CPU percentage usage also- so we can check whether our foreground process is only taking more memory
● But, if the releasing doesn’t happen correctly, then, memory accumulation happens over a long time which results in a leak.
● Due to this, memory starvation happens for other process
● Go to bash and then $df or $df -h(df=diskspace for filesystem. Used to see flash and also all other filesystem mounts)
● It shows the log for currently running process
OTHER COMMANDS:
● If we want to get more space, we clear varcore and other logs
● To search for files, we use find command (it is important). For example, we can use find to find the debug.log file.
● Environment Variables - The binaries are stored at a specific location and whenever a process asks for the file, it tells to look at the specific location using environment variables. To see all env variables, use $printenv
- ○ $echo $PATH where PATH is an environment variable name and echo is just to print
- ○ $TEMP – location where processes can store temporary files
- ○ $HOME - indicate where a user's home directory is located in the file system.
- ○ $PWD- show present working directory
- ○ $SHELL contains the path to the user's preferred shell
- ○ $TERM contains the type of the running terminal, e.g. xterm-256color.
- ○ $VISUAL contains command to run the full-fledged editor that is used for more demanding tasks, such as editing mail (e.g., vi, vim, emacs etc).
- ○ https://wiki.archlinux.org/index.php/environment_variables
● BASHRC file:
- ○ Located in user’s home directory
- ○ .bashrc is a shell script that Bash runs whenever it is started interactively.
- ○ You can edit it to set our environment variables
- ○ For example, we can set aliases in .bashrc for very long commands. It works only for us.
- ○ Note that alias works in EOS also and here it works for everyone
- ○ Fedora uses YUM Package Manager
- ○ Here, the package is RPM format
- ○ Inside Linux, everything is managed as a file including processes, devices, drivers, folders, etc…So, we can vi anything
- ○ Install using the command in bash: $rpm -i <package>.rpm
● Background and Foreground Process:
- ○ Unlike with a foreground process, the shell does not have to wait for a background process to end before it can run more processes.
- ○ To run a command as a background process, type the command and add a space and an ampersand to the end of the command. For example:
Here, While that is running in the background, the shell prompt will return.
- ○ To start a foreground process, enter a command at the prompt, e.g.,
Here, the next prompt will not appear until command1 finishes running.
● EOS maintains its own route tables.
● Loopback Address:
- ○ IPC mechanisms like sockets and pipes use this
- ○ Used by developers to test their applications. For example, two applications on same machine can open a socket to loopback address and read data b/w them.
- ○ Testing the IP stack
- ○ Inside EOS, loopback address is a unique identifier for each switch
● Tcpdump:
- ○ It is used to capture packets. (It can be used even from EOS and the command varies slightly)
- ○ For single interface, $tcpdump -i et 1/1
- ○ To write the output to a file, $tcpdump -i ma 1 -w /mnt/flash/filename.pcap
- ○ To see the capture for all interfaces, $sudo tcpdump
- ○ To listen to the traffic before it even goes to the CPU, $tcpdump -i fabric. Used for seeing vlan tagging.
- ○ $scp filename.pcap admin@switch1:/users/admin/Desktop
- ○ Note that the ‘:’ after ip address is compulsory in linux and not needed in EOS
- ○ $scp admin@my-laptop:/Users/admin/Desktop/filename.pcap .
- ○ The ‘.’ as the destination means it will copy the file to the current directory in linux
- ○ admin$sftp root@switch1
sftp> get filename.pcap
sftp> exit
admin$ ls | grep filename.pcap
- ○ The file will be there in our computer .ie. we transfered the file from switch to laptop using ftp
- ○ We first configure our ip address manually to the same subnet as the switch
- ○ Then, we $ssh admin@192.168.1.100 using your password. Ie. we connect to the management port of the switch
No comments:
Post a Comment