Stop memorizing two sets of commandsthese 7 work on Windows and Linux

If you want to use the Linux command line after using PowerShell or vice versa, you'll find many commands are the same between the two.From file management to networking, you can find many commands in common.cd Change directories The "cd" command, for "change directory," isn't particularly exciting, either in Linux or Windows.

It just does its job, which is to change the working directory, or the directory that you're currently in.On Linux, you can supply the cd command with the absolute or relative pathname you want to go to.Suppose you wanted to go to the /usr/share/doc directory, you'd type: cd /usr/share/doc If you were in your home directory and wanted to go to the docs directory that was a subdirectory of your home directory, you would type: cd docs You can go up a subdirectory relative to the current working directory by adding using ".." (two periods) as the argument: cd ..

You can go to your home directory by just using the cd command by itself.The cd command in PowerShell is similar.You can use cd followed by the pathname: cd Documents You can also use "cd .." to go up a subdirectory, as with the Linux cd command.

cd is actually an alias of the PowerShell "Set-Location" function.PowerShell defines a lot of aliases like this to be familiar to Linux users as well as MS-DOS and Command Prompt users.Commands like this that were already used in Unix and Linux helped me use my knowledge from my MS-DOS days to successfully learn the Linux command line.

mkdir Create directories The mkdir command is also another command that's useful but not very exciting.To create a new directory in Linux, use the mkdir command.To create a directory called "test" as a subdirectory of the current working directory: mkdir test The mkdir command on Linux has more options.

While cd was a built-in command on zsh, my shell of choice, it's a regular program in Linux.You can use the -p option to set the directory permissions.If you wanted a directory to, readable, writable, and searchable by its owner and off-limits to anyone else: mkdir -p 700 test mkdir takes arguments similar to that of chmod for file permissions.

The "7" means that the owner has read, write, and execute permissions, which for directories means that the owner can list files in the directory, while other users, even those in the same group, have no access at all.To do the same using symbolic permission values: mkdir -p u+rwx g-rwx o-rwx test The PowerShell version is similar: mkdir test rm Delete files, forever You can also delete files with the same rm command in Linux and Windows.You can use the Linux command to get rid of a single file: rm file Or you can use a wildcard character to generate a list of files.

To remove all .zip files in the current directory: rm *.txt When you delete files using rm, you can't get them back.They are permanently deleted, so be careful with the rm command, particularly as root and in system directories.PowerShell also has an rm command, and it's aliased to Remove-Item While Windows is usually forgiving with deleted files, you should be careful deleting files on the command line as you would be in Linux.

Files deleted using rm don't go to the Recycle bin, but are deleted directly.One difference between the Linux and Windows rm commands is that the latter works on directories as well as files, while in Linux, to delete directories, you need to use the rmdir command.ping Is that site up or down? If you want to check whether a remote site is responding or see if your internet connection is working, you can use the ping command.

To check if Google is responding on both Linux and Windows: ping google.com The two utilities behave differently on Linux and Windows.On Linux, the ping will run forever until you press Ctrl+c, and then print some summary statistics.You can set the number of times that ping will run with the -c option.

To ping four times: ping -c 4 google.com The Windows version will run four times by default.nslookup Who owns that domain name? If you want to see who owns a domain name, the nslookup command will let you do so.It exists on both Linux and Windows, and the command is exactly the same, though the output looks slightly different between the two: nslookup google.com cURL Download files from the command line cURL is a useful tool for downloading files from the command line.

It's already popular on Linux for installation scripts, but it's now installed by default on Windows PowerShell as well.To download a file on either system: curl example.com ssh Connect to remote servers in the terminal SSH is another networking tool that's ubiquitous in system administration.It's already installed on most Linux distributions.

Previously, Windows users had to install third-party tools such as PuTTY to use SSH, but PowerShell has the same OpenSSH as on Linux systems built into PowerShell.If you have an account on a remote server, you can just run the SSH command: ssh [email protected] You can set up a remote key pair so you can log in without a password.It's easy to convert between the Linux and Windows command lines.

You don't have to spend time remembering commands.If you're used to Linux, but dabble in PowerShell once in a while, you can use your favorite Linux commands.Microsoft 365 Personal OS Windows, macOS, iPhone, iPad, Android Brand Microsoft Price $100/year Developer(s) Microsoft Free trial 1 month Microsoft 365 includes access to Office apps like Word, Excel, and PowerPoint on up to five devices, 1 TB of OneDrive storage, and more.

$100 at Microsoft Expand Collapse

Read More
Related Posts