Wednesday, January 2, 2013

Windows Command Line (cmd) commands

Active Directory ADmodcmd Active Directory Bulk Modify

 CSVDE Import or Export Active Directory data 
 DSACLs Active Directory ACLs
 DSAdd Add items to active directory (user group computer) 
 DSGet View items in active directory (user group computer)
 DSQuery Search for items in active directory (user group computer)
 DSMod Modify items in active directory (user group computer)
 DSMove Move an Active directory Object
 DSRM Remove items from Active Directory

Batch Files

CALL Call one batch program from another• CHOICE Accept keyboard input to a batch file CLIP Copy STDIN to the Windows clipboard CLS Clear the screen• CMD Start a new CMD shell COLOR Change colors of the CMD window• DOSKEY Edit command line, recall commands, and create macros ECHO Display message on screen• ENDLOCAL End localisation of environment changes in a batch file• EVENTCREATE Add a message to the Windows event log EXIT Quit the current script/routine and set an errorlevel• FOR /F Loop command: against a set of files• FOR /F Loop command: against the results of another command• FOR Loop command: all options Files, Directory, List• GOTO Direct a batch program to jump to a labelled line• IF Conditionally perform a command• IFMEMBER Is the current user a member of a Workgroup LOGEVENT Write text to the event viewer LOGTIME Log the date and time in a file MAPISEND Send email from the command line MORE Display output, one screen at a time PAUSE Suspend processing of a batch file and display a message• PROMPT Change the command prompt• REM Record comments (remarks) in a batch file• RUN Start | RUN commands RUNAS Execute a program under a different user account SET Display, set, or remove session environment variables• SETLOCAL Control the visibility of environment variables• SETX Set environment variables SORT Sort input SHIFT Shift the position of batch file parameters• SLEEP Wait for x seconds START Start a program, command or batch file• TIMEOUT Delay processing of a batch file TITLE Set the window title for a CMD.EXE session• WAITFOR Wait for or send a signal WMIC WMI Commands :: Comment / Remark•

Disk Management

BOOTCFG Edit Windows boot settings BCDBOOT Create or repair a system partition BCDEDIT Manage Boot Configuration Data CONVERT Convert a FAT drive to NTFS CHKDSK Check Disk - check and repair disk problems CHKNTFS Check the NTFS file system DEFRAG Defragment hard drive DISKPART Disk Administration DISKSHADOW Volume Shadow Copy Service DriverQuery Display installed device drivers FORMAT Format a disk FREEDISK Check free disk space (in bytes) LABEL Edit a disk label MOUNTVOL Manage a volume mount point NTBACKUP Backup folders to tape SFC System File Checker VOL Display a disk label•

Files and Folders

ASSOC Change file extension associations• ASSOCIAT One step file association ATTRIB Change file attributes BITSADMIN Background Intelligent Transfer Service CACLS Change file permissions CD Change Directory - move to a specific Folder• CIPHER Encrypt or Decrypt files/folders COMP Compare the contents of two files or sets of files COMPACT Compress files or folders on an NTFS partition COMPRESS Compress individual files on an NTFS partition COPY Copy one or more files to another location• CSCcmd Client-side caching (Offline Files) DEL Delete one or more files• DELTREE Delete a folder and all subfolders DIR Display a list of files and folders• ERASE Delete one or more files• EXPAND Uncompress files EXTRACT Uncompress CAB files FC Compare two files FIND Search for a text string in a file FINDSTR Search for strings in files FORFILES Batch process multiple files FSUTIL File and Volume utilities FTP File Transfer Protocol FTYPE File extension file type associations• iCACLS Change file and folder permissions MD Create new folders• MOVE Move files from one folder to another• MKLINK Create a symbolic link (linkd) OPENFILES Query or display open files POPD Return to a previous directory saved by PUSHD• PsFile Show files opened remotely PUSHD Save and then change the current directory• QGREP Search file(s) for lines that match a given pattern RECOVER Recover a damaged file from a defective disk REN Rename a file or files• REPLACE Replace or update one file with another RD Delete folder(s)• RMTSHARE Share a folder or a printer ROBOCOPY Robust File and Folder Copy SHARE List or edit a file share or print share SHORTCUT Create a windows shortcut (.LNK file) SUBINACL Edit file and folder Permissions, Ownership and Domain TAKEOWN Take ownership of a file TOUCH Change file timestamps TREE Graphical display of folder structure TYPE Display the contents of a text file• WHERE Locate and display files in a directory tree WINDIFF Compare the contents of two files or sets of files XCACLS Change file and folder permissions XCOPY Copy files and folders

Group Policy/Windows Installer

DevCon Device Manager Command Line Utility GPRESULT Display Resultant Set of Policy information GPUPDATE Update Group Policy settings MSIEXEC Microsoft Windows Installer PsInfo List information about a system PsShutdown Shutdown or reboot a computer REGSVR32 Register or unregister a DLL SHUTDOWN Shutdown the computer SLMGR Software Licensing Management (Vista/2008) WUAUCLT Windows Update

Networking

ARP Address Resolution Protocol BROWSTAT Get domain, browser and PDC info DNSSTAT DNS Statistics GETMAC Display the Media Access Control (MAC) address IPCONFIG Configure IP NET Manage network resources NETDOM Domain Manager NETSH Configure Network Interfaces, Windows Firewall & Remote access NBTSTAT Display networking statistics (NetBIOS over TCP/IP) NETSTAT Display networking statistics (TCP/IP) NSLOOKUP Name server lookup PATHPING Trace route plus network latency and packet loss PsPing Measure network performance PING Test a network connection ROUTE Manipulate network routing tables TRACERT Trace route to a remote host

Processes

KILL Remove a program from memory PATH Display or set a search path for executable files• PsExec Execute process remotely PsKill Kill processes by name or process ID PsList List detailed information about processes PsGetSid Display the SID of a computer or a user PsSuspend Suspend processes SCHTASKS Schedule a command to run at a specific time SOON Schedule a command to run in the near future TASKLIST List running applications and services TASKKILL Remove a running process from memory TLIST Task list with full path

Printing

CON2PRT Connect or disconnect a Printer MODE Configure a system device PRINT Print a text file PRINTBRM Print queue Backup/Recovery PRNCNFG Display, configure or rename a printer PRNMNGR Add, delete, list printers set the default printer RUNDLL32 Run a DLL command (add/remove print connections)

Registry

REG Registry: Read, Set, Export, Delete keys and values REGEDIT Import or export registry settings REGINI Change Registry Permissions

Remote Desktop

CHANGE Change Terminal Server Session properties Query Process Display processes (TS/Remote Desktop) Query Session Display all sessions (TS/Remote Desktop) Query TermServer List all servers (TS/Remote Desktop) Query User Display user sessions (TS/Remote Desktop) MSTSC Terminal Server Connection (Remote Desktop Protocol) RASDIAL Manage RAS connections RASPHONE Manage RAS connections Reset Session - Delete a Remote Desktop Session TSSHUTDN Remotely shut down or reboot a terminal server WINRM Windows Remote Management WINRS Windows Remote Shell

Services

CASPOL Code Access Security Policy Tool. NETSVC Command-line Service Controller PORTQRY Display the status of ports and services PsService View and control services SC Service Control SCLIST Display Services

System Information

NOW Display the current Date and Time DATE Display or set the date• HELP Online Help LOGMAN Manage Performance Monitor MBSAcli Baseline Security Analyzer MEM Display memory usage MSINFO32 System Information NTRIGHTS Edit user account rights PERFMON Performance Monitor PsLogList Event log records SYSTEMINFO List system configuration TIME Display or set the system time• TypePerf Write performance data to a log file VER Display version information• VERIFY Verify that files have been saved• WINMSDP Windows system report WHOAMI Output the current UserName and domain

User Administration

ADDUSERS Add or list users to/from a CSV file CERTREQ Request certificate from a certification authority CleanMgr Automated cleanup of Temp files, recycle bin CON2PRT Connect or disconnect a Printer CMDKEY Manage stored usernames/passwords DELPROF Delete user profiles DIRUSE Display disk usage GLOBAL Display membership of global groups LOCAL Display membership of local groups LOGOFF Log a user off MOVEUSER Move a user from one domain to another MSG Send a message PERMS Show permissions for a user POWERCFG Configure power settings PsLoggedOn Who's logged on (locally or via resource sharing) PsPasswd Change account password SHOWGRPS List the Workgroups a user has joined SHOWMBRS List the Users who are members of a Workgroup SUBST Associate a path with a drive letter USRSTAT List domain usernames and last login Commands marked "•" are Internal commands only available within the CMD shell. All other commands (not marked with "•") are external commands. External commands may be used under the CMD shell, PowerShell, or directly from START-RUN. See also: An A-Z Index of the Windows CMD command line Microsoft Help pages: Windows XP - 2003 Server - 2008 Server

Tuesday, January 1, 2013

How to search files in Ubuntu/Linux


1. Basic file search syntax

Ubuntu is using find command for search files in the file system.Basic syntax of search is follow below style


find [path] [expression]
where path is the path is the based directory where search need to be begins.If user not specify a path then find command starts to search file based on the currant directory where the terminal points.User can specify many expressions along with search patterns and actions for achieve many purposes as describe below.

2. Finding A File Based On File name

Let say for instance user wants to find a file named as "mytext.txt" in users home directories. (Case sensitive search)

$ find /home -name ‘mytext.txt’
Let say for instance user want to find all text files which has ".txt" suffix in users home directories. (Case sensitive search)
$ find /home -name ‘*.txt’
Let say for instance user want to find all text files which contains a string named as "tex" in users home directories. Following command search each and every file whether file name contains "tex" string.(Case sensitive search)

$ find /home -name ‘*tex*’
If user wants to search for all *.txt and *.avi files then it can be specify as follows.(Case sensitive search)
$ find /home -name ‘*.mpg’ -o -name ‘*.avi’
Case insensitive searches can be achieved by using the -iname phrase with the find command.


$ find /home -iname ‘*.mpg’

3. Adding Some More Functions to Search

Searching a entire file system causes to return thousands of files for a given file name .When user need to efficiently search file , Linux systems offer to specify search parameters to reduce the number of files return for a particular search.I show some examples below to demonstrate the search conditions.

Find all "mpg" files where size of each file greater then 700MB


$ find /home/ -name ‘*.mpg’ -a -size +700M
Find all "mpg" files which are modified within 15 days

$ find /home -name '*.mpg' -a -size +700M -mtime -15

4. Adding Some Actions

User is beneficial of searching files with conditions.But when user need something to do with the search files,Linux systems is capable of manipulating files along with the search.User may need to remove all files,move files ant etc which are output as search results.I have described below some actions which are perform on searched files.

Below command will search all "mpg" files which are modified within 15 days along with the size of each file is more than 700 MB and move it to new file location "/home/harsha/".


$ find /home/ -name ‘*.mpg’ -a -size +700M -mtime -15 -exec mv ‘{}’ /my/harsha/ \;
Note:The use of "{}" and \;(there should be a space before this)
‘{}’ matches the file that was found, while \; terminate the exec statement.

I mentioned only few ways of efficiently search a file in Ubuntu/Linux systems.But there are many conditions and actions can apply for a search.