Category Archives: File Management

Path

The Path command sets the command path in the PATH environment variable (the set of directories used to search for executable files). If used without parameters, path displays the current command path.

Syntax (view syntax formatting guide):

path [[<Drive>:]<Path>[;...][;%PATH%]]
path ;

Syntax Explanation

  • [Drive:]Path: Specifies the drive and directory to set in the command path.
  • [;]: Separates directories in the command path. If used without other parameters, ; clears the existing command paths from the PATH environment variable and directs Cmd.exe to search only in the current directory.
  • %PATH%: Appends the command path to the existing set of directories listed in the PATH environment variable.
  • [/?]: Displays help at the command prompt.

When you include %PATH% in the syntax, Cmd.exe replaces it with the command path values found in the PATH environment variable, eliminating the need to manually enter these values at the command prompt.

The current directory is always searched before the directories specified in the command path.

You might have files in a directory that share the same file name but have different extensions. For example, you might have a file named Accnt.com that starts an accounting program and another file named Accnt.bat that connects your server to the accounting system network. 
The Windows operating system searches for a file by using default file name extensions in the following order of precedence: .exe, .com, .bat, and .cmd. To run Accnt.bat when Accnt.com exists in the same directory, you must include the .bat extension at the command prompt.

If two or more files in the command path have the same file name and extension, path first searches for the specified file name in the current directory. Then it searches the directories in the command path in the order that they are listed in the PATH environment variable.

If you place the path command in your Autoexec.nt file, the Windows operating system automatically appends the specified MS-DOS subsystem search path every time you log on to your computer. Cmd.exe does not use the Autoexec.nt file.

When started from a shortcut, Cmd.exe inherits the environment variables set in My Computer/Properties/Advanced/Environment.

Explanation with Examples

To search the paths C:UserTaxes, B:UserInvest, and B:Bin for external commands:

path c:usertaxes;b:userinvest;b:bin

 

 

 

Ntbackup

The ntbackup command is a built-in backup utility that allows you to backup and restore full, differential and incremental backups of critical system files and data. Ntbackup was introduced in Windows NT in 1997 and is supported on Windows NT, 2000, XP and Windows 2003. Ntbackup is not available in Windows Vista or Windows Server 2008. Instead, you should use the wbadmin command and subcommands to back up and restore your computer and files from a command prompt.

It is important to note that you cannot recover backups that you created with ntbackup by using wbadmin. However, a version of ntbackup is available as a download for Windows Server 2008 and Windows Vista users who want to recover backups that they created using ntbackup. This downloadable version of ntbackup enables you to perform recoveries only of legacy backups, and it cannot be used on computers running Windows Server 2008 or Windows Vista to create new backups. To download this version of ntbackup, see http://go.microsoft.com/fwlink/?LinkId=82917.

 

Nfsshare

The nfsshare command allow you to control Network File System (NFS) share. When you run the nfsshare command without arguments, the nfsshare command-line utility lists all Network File System (NFS) shares exported by Server for NFS. With ShareName as the only argument, nfsshare lists the properties of the NFS share identified by ShareName. When ShareName and Drive:Path are provided, nfsshare exports the folder identified by Drive:Path as ShareName. When the /delete option is used, the specified folder is no longer made available to NFS clients.

Syntax (view syntax formatting guide):

nfsshare <ShareName>=<Drive:Path> [-o <Option=value>...]
nfsshare {<ShareName> | <Drive>:<Path> | * } /delete

Syntax Explanation

The nfsshare command accepts the following options and arguments:

  • -o anon={yes | no}: Specifies whether anonymous (unmapped) users can access the shared directory. The default is no.
  • -o rw[=Host[:Host]…]: Provides read-write access to the shared directory by the hosts or client groups specified by Host. Separate host and group names with a colon (:). If Host is not specified, all hosts and client groups (except those specified with the ro option) have read-write access. If neither the ro nor the rw option is set, all clients have read-write access to the shared directory.
  • -o ro[=Host[:Host]…]: Provides read-only access to the shared directory by the hosts or client groups specified by Host. Separate host and group names with a colon (:). If Host is not specified, all clients (except those specified with the rw option) have read-only access. If the ro option is set for one or more clients, but the rw option is not set, only the clients specified with the ro option have access to the shared directory.
  • -o encoding={big5|euc-jp|euc-kr|euc-tw|gb2312-80|ksc5601|shift-jis}: Specifies the default encoding used for file and directory names and, if used, must be set to one of the following: big5 (Chinese);euc-jp (Japanese); euc-kr (Korean); euc-tw (Chinese); gb2312-80 (Simplified Chinese); ksc5601 (Korean); shift-jis (Japanese). If this is option is not set, the default encoding scheme is ANSI or, on systems configured for non-English locales, the default encoding scheme for the locale. The following are the default encoding schemes for the indicated locales: SHIFT-JIS (Japanese); KS_C_5601-1987 (Korean); GB2312-80 (Simplified Chinese); BIG5 (Traditional Chinese)
  • -o anongid=gid: Specifies that anonymous (unmapped) users will access the share directory using gid as their group identifier (GID). The default is -2. The anonymous GID will be used when reporting the owner of a file owned by an unmapped user, even if anonymous access is disabled.
  • -o anonuid=uid: Specifies that anonymous (unmapped) users will access the share directory using uid as their user identifier (UID). The default is -2. The anonymous UID will be used when reporting the owner of a file owned by an unmapped user, even if anonymous access is disabled.
  • -o root[=Host[:Host]…]: Provides root access to the shared directory by the hosts or client groups specified by Host. Separate host and group names with a colon (:). If Host is not specified, all clients have root access. If the root option is not set, no clients have root access to the shared directory.
  • /delete: If ShareName or Drive:Path is specified, deletes the specified share. If * is specified, deletes all NFS shares.

Explanation with Examples

Still to come!

Nfsadmin

The nfsdmain command allows you to manage Clients and Server for NFS. The nfsadmin command and be utilitized on local or remote computers running the Microsoft Services for Network File System (NFS). If you are logged on with an account that does not have the required privileges, you can specify a user name and password of an account that does in order to perform the nfsadmin command. The action performed by nfsadmin depends on the command arguments you supply.

Syntax (view syntax formatting guide):

nfsadmin server [ComputerName] [-u UserName[-p Password]] –l
nfsadmin server [ComputerName] [-u UserName [-p Password]] -r {client | all}
nfsadmin server [ComputerName] [-u UserName [-p Password]] {start | stop}
nfsadmin server [ComputerName] [-u UserName [-p Password]] config Option[...]
nfsadmin server [ComputerName] [-u UserName [-p Password]] creategroup Name
nfsadmin server [ComputerName] [-u UserName [-p Password]] listgroups
nfsadmin server [ComputerName] [-u UserName [-p Password]] deletegroup Name
nfsadmin server [ComputerName] [-u UserName [-p Password]] renamegroup OldName NewName
nfsadmin server [ComputerName] [-u UserName [-p Password]] addmembers Name Host[...]
nfsadmin server [ComputerName] [-u UserName [-p Password]] listmembers
nfsadmin server [ComputerName] [-u UserName [-p Password]] deletemembers Group Host[...]
nfsadmin client [ComputerName] [-u UserName [-p Password]] {start | stop}
nfsadmin client [ComputerName] [-u UserName [-p Password]] config Option[...]

Syntax Explanation

In addition to service-specific command arguments and options, nfsadmin accepts the following:

  • ComputerName: Specifies the remote computer you want to administer. You can specify the computer using a Windows Internet Name Service (WINS) name or a Domain Name System (DNS) name, or by Internet Protocol (IP) address.
  • -u UserName: Specifies the user name of the user whose credentials are to be used. It might be necessary to add the domain name to the user name in the form domainUserName
  • -p Password: Specifies the password of the user specified using the -u option. If you specify the -u option but omit the -p option, you are prompted for the user’s password.

Administering Server for NFS

Use the nfsadmin server command to administer Server for NFS. The specific action that nfsadmin server takes depends on the command option or argument you specify:

  • -l: Lists all locks held by clients.
  • -r {client | all}: Releases the locks held by a client or, if all is specified, by all clients.
  • start: Starts the Server for NFS service.
  • stop: Stops the Server for NFS service.
  • config: Specifies general settings for Server for NFS. You must supply at least one of the following options with the config command argument:
  • mapsvr=server: Sets server as the User Name Mapping server for Server for NFS. Although this option continues to be supported for compatibility with previous versions, you should use the sfuadmin utility instead.
  • auditlocation={eventlog | file | both | none}: Specifies whether events will be audited and where the events will be recorded. One of the following arguments is required.
  • eventlog: Specifies that audited events will be recorded only in the Event Viewer application log.
  • file: Specifies that audited events will be recorded only in the file specified by config fname.
  • both: Specifies that audited events will be recorded in the Event Viewer application log as well as the file specified by config fname.
  • none: Specifies that events will not be audited.
  • fname=file: Sets the file specified by file as the audit file. The default is %sfudir%lognfssvr.log
  • fsize==size: Sets size as the maximum size in megabytes of the audit file. The default maximum size is 7 MB.
  • audit=[+|-]mount [+|-]read [+|-]write [+|-]create [+|-]delete [+|-]locking [+|-]all: Specifies the events to be logged. To start logging an event, type a plus sign (+) before the event name; to stop logging an event, type a minus sign () before the event name. If the sign is omitted, the plus sign is assumed. Do not use all with any other event name.
  • lockperiod=seconds: Specifies the number of seconds that Server for NFS will wait to reclaim locks after a connection to Server for NFS has been lost and then reestablished or after the Server for NFS service has been restarted.
  • Portmapprotocol={TCP | UDP | TCP+UDP: Specifies which transport protocols Portmap supports. The default setting is TCP+UDP.
  • mountprotocol={TCP | UDP | TCP+UDP}: Specifies which transport protocols mount supports. The default setting is TCP+UDP.
  • nfsprotocol={TCP | UDP | TCP+UDP}: Specifies which transport protocols Network File System (NFS) supports. The default setting is TCP+UDP
  • nlmprotocol={TCP | UDP | TCP+UDP}: Specifies which transport protocols Network Lock Manager (NLM) supports. The default setting is TCP+UDP.
  • nsmprotocol={TCP | UDP | TCP+UDP}: Specifies which transport protocols Network Status Manager (NSM) supports. The default setting is TCP+UDP.
  • enableV3={yes | no}:Specifies whether NFS version 3 protocols will be supported. The default setting is yes.
  • renewauth={yes | no}: Specifies whether client connections will be required to be reauthenticated after the period specified by config renewauthinterval. The default setting is no.
  • renewauthinterval=seconds: Specifies the number of seconds that elapse before a client is forced to be reauthenticated if config renewauth is set to yes. The default value is 600 seconds.
  • dircache=size: Specifies the size in kilobytes of the directory cache. The number specified as size must be a multiple of 4 between 4 and 128. The default directory-cache size is 128 KB.
  • translationfile=[file]: Specifies a file containing mapping information for replacing characters in the names of files when moving them from Windows-based to UNIX-based file systems. If file is not specified, then file name character translation is disabled. If the value of translationfile is changed, you must restart the server for the change to take effect.
  • dotfileshidden={yes | no}: Specifies whether files that are created with names beginning with a period (.) will be marked as hidden in the Windows file system and consequently hidden from NFS clients. The default setting is no.
  • casesensitivelookups={yes | no}: Specifies whether directory lookups will be case sensitive (requiring exact matching of character case). You also need to disable Windows kernel case-insensitivity in order for Server for NFS to support case-sensitive file names. You can disable Windows kernel case-insensitivity by clearing the following registry key to 0: HKLMSYSTEMCurrentControlSetControlSession Managerkernel DWORD “obcaseinsensitive”
  • ntfscase={lower | upper | preserve}: Specifies whether the case of characters in the names of files in the NTFS file system will be returned in lowercase, uppercase, or in the form stored in the directory. The default setting is preserve. This setting cannot be changed if casesensitivelookups is set to yes.
  • creategroup name: Creates a new client group, giving it the specified name.
  • listgroups: Displays the names of all client groups.
  • deletegroup name:Removes the client group specified by name.
  • renamegroup OldName NewName: Changes the name of the client group specified by OldName to NewName
  • addmembers Name Host[…]: Adds Host to the client group specified by Name.
  • listmembers Name: Lists the host computers in the client group specified by Name.
  • deletemembers Group Host[…]: Removes the client specified by Host from the client group specified by Group.

NOTE: If you do not specify a command option or argument, nfsadmin server displays the current Server for NFS configuration settings.

Administering Client for NFS

Use the nfsadmin client command to administer Client for NFS. The specific action that nfsadmin client takes depends on the command argument you specify:

  • start: Starts the Client for NFS service.
  • Stop: Stops the Client for NFS service.
  • Config:Specifies general settings for Client for NFS. You must supply at least one of the following options with the config command argument:
  • fileaccess=mode: Specifies the default permission mode for files created on Network File System (NFS) servers. The mode argument consists of a three digits from 0 to 7 (inclusive) representing the default permissions granted the user, group, and others (respectively). The digits translate to UNIX-style permissions as follows: 0=none, 1=x, 2=w, 3=wx, 4=r, 5=rx, 6=rw, and 7=rwx. For example, fileaccess=750 gives rwx permission to the owner, rx permission to the group, and no access permission to others.
  • mapsvr=server: Sets server as the User Name Mapping server for Client for NFS. Although this option continues to be supported for compatibility with previous versions, you should use the sfuadmin utility instead.
  • mtype={hard | soft}: Specifies the default mount type. For a hard mount, Client for NFS continues to retry a failed RPC until it succeeds. For a soft mount, Client for NFS returns failure to the calling application after retrying the call the number of times specified by the retry option.
  • retry=number: Specifies the number of times to try to make a connection for a soft mount. This value must be from 1 to 10, inclusive. The default is 1.
  • timeout=seconds: Specifies the number of seconds to wait for a connection (remote procedure call). This value must be 0.8, 0.9, or an integer from 1 to 60, inclusive. The default is 0.8.
  • Protocol={TCP | UDP | TCP+UDP}: Specifies which transport protocols the client supports. The default setting is TCP+UDP
  • rsize=size: Specifies the size, in kilobytes, of the read buffer. This value can be 0.5, 1, 2, 4, 8, 16, or 32. The default is 32.
  • wsize=size: Specifies the size, in kilobytes, of the write buffer. This value can be 0.5, 1, 2, 4, 8, 16, or 32. The default is 32.
  • perf=default: Restores the following performance settings to default values: mtype, retry,timeout,rsize and wsize
  • fileaccess=mode: Specifies the default permission mode for files created on Network File System (NFS) servers. The mode argument consists of a three digits from 0 to 7 (inclusive) representing the default permissions granted the user, group, and others (respectively). The digits translate to UNIX-style permissions as follows: 0=none, 1=x, 2=w, 3=wx, 4=r, 5=rx, 6=rw, and 7=rwx. For example, fileaccess=750 gives rwx permission to the owner, rx permission to the group, and no access permission to others.

NOTE: If you do not specify a command option or argument, nfsadmin client displays the current Client for NFS configuration settings.

 

Compact

The compact command is used to compress data on NTFS volumes from the Windows Command Prompt or command line. It can also be used to display the current compression status of folders or files.

Syntax (view syntax formatting guide):

compact [/c | /u] [/s[:Dir]] [/a] [/i] [/f] [/q] [FileName[...]]

Syntax Explanation:

  • /c: Compresses the specified directory or file or the current directory if no directory is specified.
  • /u: Uncompresses the specified directory or file or the current directory if no directory is specified.
  • /s[:Dir]: Performs directory recursion. Applies the compact command to all subdirectories of the specified directory (or of the current directory if none is specified).
  • /a: Displays hidden or system files that may be compressed.
  • /i: Ignores any errors and continuess with the compression.
  • /f: Forces compression or uncompression of the specified directory or file. /f is used in the case of a file that was partly compressed when the operation was interrupted by a system crash. To force the file to be compressed in its entirety, use the /c and /f parameters and specify the partially compressed file.
  • /q: Reports only the most essential information instead of the default of verbose information.
  • FileName: Specifies the file or directory. You can use multiple file names, and the * and ? wildcard characters.
  • /?: Displays help at the command prompt.

Explanation with Examples:

To view the compression status of the current folder, execute this command:

compact

To compress all of the Microsoft Word documents in the current folder and all subfolders, execute this command:

compact /c /s *.doc

Comp

The comp command is used to compare the contents of two files at the Windows Command Prompt. This command line tool is often used to discover the differences between two files or to find duplicate files. Many people think that the Command Prompt in Windows is DOS, but it’s actually a Windows 32-bit application (on 32-bit Windows) or a Windows 64-bit application (on 64-bit Windows) that provides a text mode (command line) interface to the system. While you may have searched for DOS comp command, know that the instructions here are for the command you are seeking.

Syntax (view syntax formatting guide):

comp Data1 Data2 [/d] [/a] [/l] [/n=Number] [/c] [/?]

Syntax Explanation:

  • <Data1>: Specifies the name of the first file to be compared. Multiple files can be specified using wildcards (* and ?), such as QrtRpt*.rpt.
  • <Data2>: Specifies the name of the second file to be compared. Multiple files can be specified using wildcards (* and ?).
  • /d: By default, differences are displayed in hexadecimal encoded format. This switch changes the output to decimal format.
  • /a: Displays differences as characters instead of hexadecimal or decimal codes.
  • /n=Number: Compares the number of lines specified in each file. The comparison occurs even if the files are different sizes.
  • /c: Performs a case insensitive search. The default is a case sensitive search.
  • /?: Displays help for the command.

Explanation with Examples:

The comp command is mostly used with text files, but it may be used to compare binary files as well. Many different file types are actually stored as text, including:

  • HTML
  • RTF
  • XML
  • CSS
  • INI
  • TXT
  • CFG
  • NFO
  • ASP
  • PHP

In the examples presented here, two simple text files are used. They are named file1.txt and file2.txt. The following image shows their contents displayed using the type command from the Windows command line.

File1.txt and File2.txt Contents Displayed

File1.txt and File2.txt Contents Displayed

If you use the comp command to compare two files of different sizes, by default, it will simply inform you of the difference in size and will not perform further processing. However, you can use the /n switch to direct it to process the first few lines regardless of file size differences. The following image shows an example of the command comparing two files of different sizes, but inspecting only the first 2 lines and displaying the output as text with the /a switch as well.

Comparing Two Files with Limited Lines

Comparing Two Files with Limited Lines