Bootcamp linux commands

Preview:

Citation preview

BootcampLinux Commands...

@Nexthoughts

Background of Linux

Version of UNIXLinus Torvalds – Creator of LinuxOpen Source Operating SystemFree SoftwareSource Code Available

Where is Linux used?

→ 75% of respondents were already using Linux and another 14% were evaluating it

→ 43% of all web sites use Linux servers running the Apache Web server

How Linux is used?Personal WorkstationFile and Print ServerInternet Service ProviderThree-tier Client/ServerAbout Kernel:Linux kernel for freeKernel is central componentKernel can be customized to user’s needs

Unix Commands

A command is a program which interacts with the kernel to provide the environment and perform the functions called for by the user. A command can be: a built-in shell command; an executable shell file, known as a shell script; or a source compiled, object code file.

The shell is a command line interpreter. The user interacts with the kernel through the shell. You can write ASCII (text) scripts to be acted upon by a shell.

Taking Help

The man command displays reference pages for the command you specify.The UNIX man pages (man is short for manual ) cover every command available.To search for a man page, enter man followed by the name of the command to find . For example: % man cpOr try: % man man

Files Related Commands

ls

List directory contentsHas whole bunch of options.• % lsall files except those starting with a “.”• % ls -aall• % ls -A all without “.” and “..”

• % ls -Fappend “/” to dirs and “*” to executables• % ls -llong format• % ls -al• % ls -ltsort by modification time (latest - earliest)• % ls -ltrreverse

cp

Copies files / directories.

% cp [options] <source> <destination>

% cp file1 file2

% cp file1 [file2] … /directory

Useful option: -i to prevent overwriting existing files and prompt the user to confirm.

mv

Moves or renames files/directories.

% mv <source> <destination>The <source> gets removed

% mv file1 dir/

% mv dir1 dir2

rm

Removes file(s) and/or directories.

% rm file1 [file2]

% rm -r dir1 [dir2]

Directories

cd

Changes your current directory to a new one.

% cd /some/other/dirAbsolute path

% cd subdirAssuming subdir is in the current directory.

% cdReturns you to your home directory.

mkdir

Creates a directory.

% mkdir newdir

pwd

Displays personal working directory, i.e. your current directory.

% pwd

rmdir

Removes a directory.

% rmdir dirname

chmodChanges file permissionsPossible invocations% chmod 600 filename-rw------- 1 user group 2785 Feb 8 14:18 filename(a bit not intuitive where 600 comes from) (owner) (group) (others) chmod [number][number][number] file1

Number = (read)4 + (write)2 + (execute)1

Example: Chmod 754 file1

for owner: read, write and execute permissions (4+2+1) for group: read and execute permissions (4+0+1) for others: only read permission (4+0+0)

chmodSome of the things these commands manipulate:

The time stamp: Each file has three dates associated with it. These are creation time, last modification time and last access time.

The owner: the owner of files

The group: the group of users

The permissions: read, write, execute permissions of files. The permissions tell unix who can access what file, or change it, or, in the case of programs, execute it. Each of these permissions can be toggled separately for the owner, the group, and all the other users.

chmod

drwxr-xr-x 2 dag users 6 Dec 6 2000 netscape

owne

r

grou

p

othe

rs file name

read, write, execute permissions of files

grep

Searches its input for a pattern.The pattern can be a simple substring or a complex regular expression.If a line matches, it’s directed to STDOUT; otherwise, it’s discarded.

% echo “blah-foo” | grep blahWill print the matching line% echo “blah-foo” | grep zeeWill not.

alias

Defined a new name for a command

% aliaswith no arguments lists currently active aliases

% alias newcommand oldcommanddefines a newcommand

ssh

ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine.It provide secure encrypted communications between two untrusted hosts over an insecure network.

ssh -i /home/narendra/.ssh/keir_wp.pem -o IdentitiesOnly=yes ubuntu@52.19.236.56 -v

scpScp (Secure Copy) is a command line tool to copy or transfer files across hosts. It uses the same kind of security mechanism like the ssh program. It uses an ssh connection in the background to perform the file transfer.

Scp <source> <destination>

Copy the file "foobar.txt" from a remote host to the local host

scp your_username@remotehost.edu:foobar.txt /some/local/directory

Copy the file "foobar.txt" from remote host "rh1.edu" to remote host "rh2.edu"

clear

Clears the screen

There’s an alias for it: Ctrl+L

Example sequence:% cal% clear% calCtrl+L

exit / logout

Exit from your login session.

% exit

% logout

shutdown

Causes system to shutdown or reboot cleanly.

May require superuser privileges

% shutdown -h now - stop% shutdown -r now - reboot

Thanks for listening...