27
Bootcamp Linux Commands... @Nexthoughts

Bootcamp linux commands

Embed Size (px)

Citation preview

Page 1: Bootcamp linux commands

BootcampLinux Commands...

@Nexthoughts

Page 2: Bootcamp linux commands

Background of Linux

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

Page 3: Bootcamp linux commands

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

Page 4: Bootcamp linux commands

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

Page 5: Bootcamp linux commands

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.

Page 6: Bootcamp linux commands

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

Page 7: Bootcamp linux commands

Files Related Commands

Page 8: Bootcamp linux 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

Page 9: Bootcamp linux commands

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.

Page 10: Bootcamp linux commands

mv

Moves or renames files/directories.

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

% mv file1 dir/

% mv dir1 dir2

Page 11: Bootcamp linux commands

rm

Removes file(s) and/or directories.

% rm file1 [file2]

% rm -r dir1 [dir2]

Page 12: Bootcamp linux commands

Directories

Page 13: Bootcamp linux commands

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.

Page 14: Bootcamp linux commands

mkdir

Creates a directory.

% mkdir newdir

Page 15: Bootcamp linux commands

pwd

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

% pwd

Page 16: Bootcamp linux commands

rmdir

Removes a directory.

% rmdir dirname

Page 17: Bootcamp linux commands

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)

Page 18: Bootcamp linux commands

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.

Page 19: Bootcamp linux commands

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

Page 20: Bootcamp linux commands

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.

Page 21: Bootcamp linux commands

alias

Defined a new name for a command

% aliaswith no arguments lists currently active aliases

% alias newcommand oldcommanddefines a newcommand

Page 22: Bootcamp linux commands

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 [email protected] -v

Page 23: Bootcamp linux commands

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 [email protected]:foobar.txt /some/local/directory

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

Page 24: Bootcamp linux commands

clear

Clears the screen

There’s an alias for it: Ctrl+L

Example sequence:% cal% clear% calCtrl+L

Page 25: Bootcamp linux commands

exit / logout

Exit from your login session.

% exit

% logout

Page 26: Bootcamp linux commands

shutdown

Causes system to shutdown or reboot cleanly.

May require superuser privileges

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

Page 27: Bootcamp linux commands

Thanks for listening...