<<

Webinar TECH Expert Meet ! Part #2 PLAN

• Introduction-Plan

• Wrap up of commands from part #1

• Commands and use cases ( , , , touch, nano-tiny, )

• Goals for the next chapter

Webinar Tech Expert 2 Wrap up

To continue exploration of Linux – you should be able to navigate in the filesystem and login as ( access folders, view content of folders and understand your location in the system’s directories )

– login as superuser ( Password is *hidden* ) – change that helps you to move between folders ( example: cd //to/folder ) – displays your current location in the filesystem – list of content in the directory

Webinar Tech Expert 3 Copy, Move, Remove!

cp – Copy command, used to copy files and directories

Syntax: cp [options] source destination

option description cp -a archive files cp -f force copy by removing the destination if needed cp -i interactive - ask before overwrite cp -l files instead of copy cp -L follow symbolic links cp -n no file overwrite cp -R recursive copy (including hidden files) cp -u update - copy when source is newer than dest cp -v verbose - print informative messages

Webinar Tech Expert 4 Copy command & relative path

Example of use of CP command to move syslog file to different folder :

NOTE: Reminder about absolute & relative path to file/directory case. In this example – relative path is used, because we are currently in the folder contains the file, if we need to copy the file while being in different directory – we will specify /path/to/file using absolute path.

Webinar Tech Expert 5 Copy command & absolute path

Example of CP command with absolute path specification, starting from root directory ( / ) and path straight to file wms.log

Note: Yet again we used relative path to folder to define destination point of the file by using shortcut “./” which represents shortcut to current folder. Without shortcut absolute path will be:

cp /var/log/wms.log /mnt/backups/

Webinar Tech Expert 6 Move command

MV – “Move” command transfers files or directories from one place to another. It supports moving single files, multiple files and directories. It can prompt before overwriting and has an option to only move files that are newer than the destination Syntax: mv [options] source destination

option description mv -f force move by overwriting destination file without prompt mv -i interactive prompt before overwrite mv -u update - move when source is newer than destination mv -v verbose - print source and destination files

Webinar Tech Expert 7 Copy & Move usage Both CP & MV commands can be used to do the same operation. For example, to rename the file, move it to the other destination. The difference is that CP command creates another copy and MV command moves the actual file without leaving a copy in it’s current folder. Example of rename of file move_me.txt to renamed.txt. There is no references to move_me.txt

Example of rename of the file with CP command. The actual file is still present in the folder along with the renamed copy.

Webinar Tech Expert 8 Clean up time – Remove command

RM - Remove command, used to remove objects such as files, directories. Attention: By default, it does not remove directories. Syntax: rm [options] source

option description

-f, Ignore nonexistant files, and never prompt before removing. -i Prompt before every removal. -I Prompt once before removing more than three files, or when removing recursively. This option is intrusive than -i, but still gives protection against mistakes. -r, Remove directories and their contents recursively.

-d, Remove empty directories. This option permits you to remove a directory without specifying -r/- R/--recursive, provided that the directory is empty. In other words, rm -d is equivalent to using . -v, Verbose mode; explain all times what is being done.

Webinar Tech Expert 9 Additional warning about RM command

WARNING!

Be careful while using “RM” command, if you use it without paying attention – you can delete all files from root ( / ) directory, including binary files, required for work of the system.

Webinar Tech Expert 10 Time to create your own file! Touch command

Touch – command Touch is used to create an empty file in UNIX/Linux systems. Syntax: touch file_name

In practice – touch can be used to create a “stash” for logs when you’re trying to troubleshoot an issue and you’re trying to copy all syslog data to somewhere. It could even be used for some internal notes as well.

Webinar Tech Expert 11 Nano-tiny – your cheap Microsoft Word from the world of Linux

Nano-tiny is a text editor in Linux. By using nano-tiny you can change values/ variables in configuration files of WMS. Syntax: nano-tiny /path/to/folder/file_name

Some hints about usage: To save changes& in nano-tiny, you need to press Ctrl+X combination and then press “y” to accept changes or “No” to discard changes. Then you will be prompted to specify a file name. You can either press “Enter” and save with the old name or type a new name for the file and press “Enter” and then confirm the change.

Webinar Tech Expert Nano-tiny command / Text Editor basic look

Webinar Tech Expert 13 Cat – not an animal, but a versatile command

The cat command (short for “concatenate “) is one of the most frequently used commands in Linux/Unix and Apple Mac OS X operating systems. The cat command allows us to create single or multiple files, view content of a file, concatenate files and redirect output into the terminal or other files.

• Example of text file creation with cat command:

• Example of using the cat command to view content of the file:

Webinar Tech Expert Cat syntax

To copy content of one file to another, use the following command: cat file_name1.txt > file_name2.txt To display content of the file : cat file_name

Create a NEW text file: cat filename.txt NOTE: To edit an existing file – use nano-tiny

Webinar Tech Expert Don’t forget about built-in manuals while playing with commands!

Command – MAN “man” command in Linux is used to display the user manual of any command that we can run on the terminal. It provides a detailed view of the command which includes name, synopsis, description, options, exit status, return values, errors, files, versions, examples, authors and see also.

Webinar Tech Expert Goals for the next video

• To be able to copy file wms.log ( location of wms.log file is at /var/log/ directory ) to /mnt/backups/ folder with the name wms.log.tar.gz ( after that, go to WMS -> Backups and check the content of backups ;) )

• To be able to create a text file in /home/admin/ folder, rename it and move it to the folder /mnt/backups/

• To be able to display the content of wms.log file with cat command and move output from wms.log file to your own file

• Try to add some custom provision parameters (https://confluence.wildix.com/ display/DOC/Provisioning+Custom+Settings ) to provision.conf file in /rw2/ etc/ with nano-tiny command

Webinar Tech Expert