Sunday, January 27, 2013

Windows and Unix common commands

WindowsUnixDescription
attrib

change(clear or set) the attribute of the file

cdpwdprint current working directory
cd <dir>cd <dir>change directory
clsclearclear screen
cmdStarts a new instance of the Windows command interpreter
copycpcopy
cp /mySrc .
date, timedateprint current date and/or time
delrmdelete
deltreerm - rrecursively delete entire directory tree
dirlslist files and directories
ls attributes:
-a Include hidden fiels (beginning with .)
-l long format
-s sort by time modified
-r reverse sort 
doskey /hhistoryprint history
editvi etc.create new file, show edit window

common vi commands:
/<text> - search forward
n - next occurrence
?<text> - search backward
n - previous occurrence
:set number - show line number
:q | :quit | :q! - quit
exitexit
Ctrl-D
exit
findfinds files/folders or string in files
Ex.
dir c:\ /s /b | find "CPU" - display the file names on drive C that contain the string "CPU"
find . -name "foo*"
findgrepsearch
grep -n 'UnknownServiceException' */*/*/server.log
grep -rni "string" * .*
grep -E "a|b"
  r = recursive i.e, search subdirectories within the current directory
  n = to print the line numbers to stdout
  i = case insensitive search
  .* = hidden files/directory
  -E = extended regex (i.e., may use | for or) 
helpmanhelp/manual
displays all available commands & how to use them
ipconfig /allipconfig -aprint network details
mkdirmkdircreate new folder/directory
movemvmove file or folder
rmdirrmdirremove folder/directory
setenvset environment variable
set Pathecho $PATHprint value of environment var PATH
startstarting/opening a command/program
List of commands for Windows XP, Vista and Windows 7: http://ss64.com/nt/run.html
Ex.
subst notepad
start /d "C:\Program Files (x86)\Notepad++" notepad++.exe -> start the executable and close the command prompt that called it
substsubstituting path
subst R: D:\temp\temp
typecatdisplay contents of a file, concatenate files or create a new file
Ex.
cat > 1.txt
This is the first line.
- creates a simple text file. ^D mrks the end of file.
cat 1.txt - display contents of 1.txt
cat 1.txt 2.txt > 3.txt - concatenate 1.txt and 2.txt ans save it in 3.txt
treefind .,
ls -R
print directory structure
lessdisplay the contents of a text file on console
lnmake link
Types:
1. Hard link (default) - Points to a file through inode number. If the original file's name is changed, hard link still points to same file.
2. Symbolic link (ln -s) - Points to a file through name. If the original file's name is changed, symbolic link still points to the original name and does not point anymore to the original file. If the original file's content is changed, symbolic link still points to the same file.
ln -s myFolder myShortcut - create
ln -sfn myFolder2 myShortcut - update
   -f = force
   -n = treat LINK_NAME as a normal file if it is a symbolic link to a directory, else LINK_NAME  will be treated as symbolic link and will not effectively remove link to previous target and point to new target
printenvprint environment variables
tararchive/extract
tar -xvf sample.tar.gz

PATH
WindowsUnixDescription
\/Directory separator, e.g. C:\user\docs\sample.txt
/-Switch, e.g. dir /w
[drive letter:]\ or
\\[server name]\[volume]\
/Root directory
..Current directory
....Parent directory
~Home directory - $HOME var in UNIX, which usually is /home/username
C:\user\docs\sample.txt
docs\sample.txt
A:pic.jpg \\server01\user\docs\sample.txt
//home/user/docs/Letter.txt .
/inthisdir
../../greatgrandparent ~/.rcinfotd>
Sample paths


Source:
https://en.wikipedia.org/wiki/Path_(computing)

No comments:

Post a Comment